在这种情况下,我正在遍历 Cloud Firestore 集合中的文档,如何获取文档的路径?
children: snapshot.data.documents.map((document) {
return new ListTile(
//want to get the document path here
title: new Text(document.path),
);
Run Code Online (Sandbox Code Playgroud)
显然,您可以访问路径数据,但是我在 github 上找到的解释非常不清楚 https://github.com/flutter/plugins/pull/244
以一看源代码:
在这一行中,您可以看到这_path是 的私有财产DocumentSnapshot。
此外,您可以看到path 可以在DocumentReference,此处访问。
这导致以下代码:
children: snapshot.data.documents.map((document) {
return new ListTile(
title: new Text(document.reference.path), // this will return the path
);
Run Code Online (Sandbox Code Playgroud)
请注意我如何只添加 .reference.
| 归档时间: |
|
| 查看次数: |
1848 次 |
| 最近记录: |