In a situation like this where I am iterating through documents inside a collection of Cloud Firestore, how can I get the path of the documents?
children: snapshot.data.documents.map((document) {
return new ListTile(
//want to get the document path here
title: new Text(document.path),
);
Apparently, you can access the path data, but the explanation I found on github was very unclear https://github.com/flutter/plugins/pull/244
Taking a look at the source code:
In this line you can see that _path
is a private property of DocumentSnapshot
.
Also, you can see that the path
is accessible in a DocumentReference
, here.
This results in the following code:
children: snapshot.data.documents.map((document) {
return new ListTile(
title: new Text(document.reference.path), // this will return the path
);
Notice how I only added .reference
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With