How to get the document id after adding document in Cloud Firestore in Dart

Posted by Jessica Taylor | Updated on

If you want to get the document id after adding document in Cloud Firestore in Dart. You can try the following:

Since add() method creates new document and autogenerates id, you don’t have to explicitly call document() method

Or if you want to use “then” callback try the following:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers