Home > Blockchain >  Read key value from array using document id (Flutter)
Read key value from array using document id (Flutter)

Time:07-28

Very new to flutter. I want to retrieve arrays of notifications using a specific document id and display [date, message, type] in my App. Tried to google but can't seem to find any solution.

enter image description here

CodePudding user response:

Try this with this you will get specific document's data.

firebaseFirestore.collection('Customer').doc('paste-your-document-id').get();

you'll get whole data of Notification data then use it accordingly.

CodePudding user response:

Whole Notification data will print.

FirebaseFirestore.instance.collection("Customer").doc(document_id).get().then((value) {
   Map<dynamic, dynamic> map = value.data();
   for(var element in map.values) {
     element.asMap().forEach((index, firebaseValue) {
       print(index);
       print('${firebaseValue['Date']}');
       print('${firebaseValue['Message']}');
       print('${firebaseValue['Type']}');
     });
   }
  }
);
  • Related