【发布时间】:2020-08-31 00:56:33
【问题描述】:
我正在尝试从 firestore 中检索文档并将其存储到列表中,但我正在返回 [Instance of 'QueryDocumentSnapshot', Instance of 'QueryDocumentSnapshot']。此外,它不返回文档列表,但字段作为数组的长度仅为 2,但我在“组织”集合中有 6 个文档。我在 SO 上问过类似的问题,但没有得到正确的答案。
这是我为获取文档列表而实现的代码:
Future<List> getHistory() async {
List history;
final List<DocumentSnapshot> documents =
(await FirebaseFirestore.instance.collection("Org").get()).docs;
history = documents.map((documentSnapshot) => documentSnapshot).toList();
return history;
}
@override
initState() {
emailInputController = new TextEditingController();
pwdInputController = new TextEditingController();
setlist();
super.initState();
Firebase.initializeApp();
}
void setlist()async {
List list = await getHistory();
print(list)
}
【问题讨论】:
标签: firebase flutter google-cloud-firestore