How can i get document id in Flutter Firestore?

In Flutter Firestore integration Firestore save data in the form of Documents and Collections.

Unlike SQl database in firestore there are no tables and rows. Always data will be store in the form of Documents.

What is Firestore Document?

A unit of Storage space in firestore is called Document.

These documents are stored inside collections.

Each Document resides inside collection, means collections are containers for the Documents.

Each Document contains unique represented by its id. This id called documentId


To get DocumentId for any document we need to create reference for that Document.

docRef:= client.Collection("collectionname").Doc("docname")



from instance of docRef we will get the Docuement id