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