[英]Flutter: futurebuilder of firestore documents
我想獲取一些用戶的文檔(在我的收藏集中:用戶)。 我將所有想要的ID存儲在列表中。
List shortIDList = [12345, 23425, 32453]
我正在嘗試使用此功能來從shortIDList獲取用戶。
shortIDList.forEach((element) => getFirestoreUsers(st: element));
getFirestoreUsers({String st}) async {
await Firestore.instance
.collection('users')
.document('$st')
.get()
.then((DocumentSnapshot ds) {
print(ds.data);
// I would like to add all these documents to a futurebuilder
});
}
我想將所有文檔添加到新列表中?我可以在futurebuilder中使用該文檔,以顯示所有用戶信息示例:個人資料圖片,姓名等。
那可能嗎?
謝謝!
您正在使用列表,但數據由json保存請嘗試使用此json格式了解更多信息,請點擊此處
我找到了解決方案:
您可以將其添加到列表中。
myList.add(ds.data);
但是您必須定義列表:
List<Map<String, dynamic>> myList = List<Map<String, dynamic>>();
然后可以在futureBuilder中使用它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.