I am using below code to add document in firestore collection in a flutter application. I am not getting an idea that on how to add the document id in the document. Please guide
Use document() with no arguments to first generate a reference to a document with a random ID, then use setData() to create it and add the documentID as part of the new document:
DocumentReference ref = Firestore.instance.collection("posts1").document();
ref.setData({
"post_id": ref.documentID,
// ... add more fields here
})