在Flutter中获取Cloud Firestore文档的路径

dshukertjr

在这种情况下,我要遍历Cloud 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

创造者或可能不是

以一看源代码

这一行中,您可以看到_path是的私有属性DocumentSnapshot

此外,您可以看到path 可以访问DocumentReference在这里

这将导致以下代码:

children: snapshot.data.documents.map((document) {
  return new ListTile(
    title: new Text(document.reference.path), // this will return the path
);

注意 如何添加的.reference

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Firestore获取已查询文档的路径

Cloud Firestore查询以获取文档ID,Flutter

Cloud Firestore多个文档和未知的收集路径

在flutter中从cloud_firestore删除文档

如何获取文档路径以便在Firestore中删除/编辑文档?

在Firestore Cloud功能中获取文档

如何使用变量在安全规则中构建Firestore文档的路径

Flutter - 如何仅获取 Cloud Firestore 中列表中不包含的特定值的文档?

如何从Cloud Firestore中获取user.uid等于flutter中的文档ID的数据?

如何获取文档列表而不在Flutter Cloud Firestore中侦听更改?

从Flutter中的Firestore查询单个文档(cloud_firestore插件)

如何在 Flutter 上获取 Cloud Firestore 上的文档 ID

Flutter-从Cloud Firestore中的文档中删除特定字段?

将数据从Cloud Firestore获取到Flutter的ListView中

无法使用 Cloud Firestore 和 Flutter 在 ListView 中获取

使用 Flutter 在 Cloud Firestore 中创建文档

如何使用Flutter监听Cloud Firestore中的文档更改?

如何使用flutter从Cloud Firestore中删除特定文档?

在Flutter Cloud Firestore中设置自定义文档ID

使用 StreamProvider 从 Flutter 中的 Firestore 中获取单个文档

如何使用Flutter从Firestore中的集合中获取特定文档

在Cloud Firestore中删除文档

在Matlab中获取“文档”路径

SwiftUI:如何迭代 Cloud Firestore 集合中的文档并获取数据?

在Firebase Cloud Functions(Firestore)中获取文档ID

如何在 Cloud Firestore Swift 中获取文档的 UID

如何获取集合Cloud Firestore中的文档ID列表?

是否可以在Firestore Cloud Function中获取所有文档?

Cloud Firestore安全规则-在列表请求中获取父文档