在这样的情况下,我在云 Firestore 集合中迭代文档,如何获取文档的路径?
children: snapshot.data.documents.map((document) {
return new ListTile(
//want to get the document path here
title: new Text(document.path),
);
显然,你可以访问路径数据,但我在 github 上找到的解释非常不清楚https://github.com/flutter/plugins/pull/244
1 回答
看一下源代码:
在这条线中,您可以看到
_path
是DocumentSnapshot的私有属性。此外,您可以看到
path
可以在DocumentReference,这里中访问。这导致以下代码:
请注意我是如何添加
.reference
的。