【发布时间】:2021-08-10 13:44:51
【问题描述】:
This is the structure你好,如何从firestore中检索特定文档字段内的地图以及如何在应用程序中将其显示为列表。这怎么可能实现?有人可以分享一个示例 sn-p 代码。例如在“Collection-Doc-Field-{key : value}”中,我想显示字段中的地图。
更新:
Expanded(
child: new ListView(
children: snapshot.data
.get('$field')
.map((DocumentSnapshot document) {
return new ListTile(
title: Column(
children: (document.data()['$field']
as Map<String, dynamic>)
.entries
.map((e) => ListTile(
title: Text(e.key),
trailing: Text(e.value.toString())))
.toList())
//subtitle: new Text(document.data()['Subjects']),
);
}).toList(),
),
),
这就是我尝试显示字段地图的方式,但最终出现此错误
The following _TypeError was thrown building StreamBuilder<DocumentSnapshot>(dirty, state: _StreamBuilderBaseState<DocumentSnapshot, AsyncSnapshot<DocumentSnapshot>>#d3cf2):
type '(DocumentSnapshot) => ListTile' is not a subtype of type '(String, dynamic) => MapEntry<dynamic, dynamic>' of 'transform'
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore