How to get document ids of a firestore collection

后端 未结 1 780
天涯浪人
天涯浪人 2021-01-29 07:25

Here is my firestore strcuture. i want to get \'RecodeBook\' collections\'s document id\'s to a List in dart.

i looked everywhere for a solution here. but i could not fi

相关标签:
1条回答
  • 2021-01-29 07:45

    Use getDocuments() method, you'll end up with querysnapshot. Get DocumentSnapshot with .documents. Print their documentId in a loop.

    QuerySnapshot querySnapshot = await Firestore.instance.collection("RecodeBook").getDocuments();
    var list = querySnapshot.documents;
    list.forEach((f) {
      print(f.documentID);
    });
    
    0 讨论(0)
提交回复
热议问题