Reputation: 3371
How do I get the generated documentID of a document in Firestore in Flutter?
I know I can access the various fields of a document like this:
return Firestore().collection(postPath).data.documents.forEach((response) {
nodeList.add(Post(
// response.data().id - how do i get the UID (example: -LUoDIu4wlVksjbbfIWE)?
response['content'],
response['date'],
response['flair'],
response['location'],
response['username'],
));
});
But I am unsure of the method to call get the UID of the document.
Upvotes: 1
Views: 3754
Reputation: 18730
You are looking for documentId property.
String id = response.documentID;
If documentId property does not exist for your response object, update the cloud_firestore plugin to a newer version.
Upvotes: 5