Search code examples
firebasefluttergoogle-cloud-firestoredata-retrieval

Retrieve data from a firestore - Firebase - Flutter


i am having a problem retrieving data from my firestore application .. i have a map of map of strings in each document of the Snapshot and i don't know how to retrieve it .. i tried to search but found nothing ..

can anyone help ?!

i can't post images so here it is link for the hierarchy of the data base

https://drive.google.com/open?id=1tmNrg3Ce6WBv5XIlARPSVKCiK_dkawnr

enter image description here


Solution

  • You can either use DataCollection and let the FireStore handle the ID or for this particular problem .. if we assumed you had a QuerySnapshot snapshot

    snapshot.documents.forEach((doc){
      doc.data.forEach((k,v)//at which k is key and v is value 
      {
        print('${k}: ${v}');
        object obj = new object();
        obj.setObj(v['1'] ?? '',v['2'] ?? '',v['3'] ??'');
        objectList.add(obj);
      });
    });