Flutter:如何在Firestore中获取集合的所有文档名称

编程入门 行业动态 更新时间:2024-10-27 14:33:46
本文介绍了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中获取集合的所有文档名称

本文发布于:2023-10-23 22:25:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   文档   如何在   Flutter   Firestore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!