如何从列表<DocumentSnapshot>

我用Firestore获取了一个集合的querysnapshot并得到List。 要在列表中获取特定项目,有必要将数字放在[]中,但是我想获取特定DocumentId的Documentsnapshot。有什么办法吗?

我尝试了indexOf,但返回-1。

chj950109 回答:如何从列表<DocumentSnapshot>

您可以执行以下操作:

snapshot.documents.firstWhere((doc) => doc.documentID == 'id',orElse: () => null)
本文链接:https://www.f2er.com/3146279.html

大家都在问