本文介绍了Flutter:如何在Firestore中获取集合的所有文档名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在使用Firestore在Flutter中制作一个应用程序,我将遍历集合中的所有文档,并且想要获得文档名称(id)和文档字段,并对此进行处理.我已经建立了一个显示数据的列表视图,但是对此我无能为力,例如,将其添加到列表或其他内容中. 谢谢
I make an app in Flutter with Firestore now I would go through all documents in a collection and I want to get the document name (id) and the field of the documents and do something with that. I have already make a listview where the data is displayed but I can't do something with that, for example, add it to a list or something. Thanks
推荐答案您可以通过获取以下文档列表来做到这一点:
You can do that by getting list of documents like:
final QuerySnapshot result = await Firestore.instance.collection('myCollection').getDocuments(); final List<DocumentSnapshot> documents = result.documents;然后您可以遍历此列表并获取数据:
And after that you can iterate this list and get data:
documents.forEach((data) => print(data));更多推荐
Flutter:如何在Firestore中获取集合的所有文档名称
发布评论