I am trying to use Uuid.v4 but when im fetching the data it come back as null. I found out that to fetch the docs id I need to generate id's like : bIEUVI7MQtfWFJYU99yO is there any way to generate id like this from flutter?
1 Answer
Just create a reference of an empty document like this, it will generate automatically your document ID:
final documentReference = FirebaseFirestore.instance.collection('collectionName').doc();
final docId = documentReference.id;
-
4Note that you can use any collection ID, e.g.
FirebaseFirestore.instance.collection('_').doc();
. The generated doc ID isn't linked to any specific collection. Commented Apr 30, 2021 at 12:26 -
2Didn't knew this one @RenaudTarnec thanks for mentioning it Commented Apr 30, 2021 at 12:29