QuerySnapshot querySnapshot = await _collectionRef
.limit(1)
.orderBy('date')
.getDocuments();
var list = querySnapshot.documents;
querySnapshot.documents.map((document) {
print('Document : $document'); // not printing anything.
});
if(list.length > 0) {
print('ID : ${list[0].documentID}'); // not working
}
This is the exact code i tried... What is the mistake in the code?
According to the API documentation, DocumentSnapshot has a documentId property, so I would expect this to work:
querySnapshot.documents[0].documentID
product.id
documentID is deprecated and shouldn't be used. Deprecated in favor of .id.
Try replacing the use of the deprecated member with the replacement.
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