Home > Mobile >  Filter data get from doc
Filter data get from doc

Time:04-05

I am getting data from firestore like this

    await FirebaseFirestore.instance.collection(LIKE_COLLECTION).doc(globalProviderState.getID).get().then((value){
      print(value);
    });

I want to get value which is in data but its showing Instance of '_JsonDocumentSnapshot';

This is how it looks like in firestore i just want to print all oppositeId which is in doc.

enter image description here

CodePudding user response:

value in your print statement is of type DocumentSnapshot. You have to call .data() to get the actual value (Map<String, dynamic>).

See below

await FirebaseFirestore.instance
    .collection(LIKE_COLLECTION)
    .doc(globalProviderState.getID)
    .get()
    .then((value) {
  print(value.data()); // <-- .data() called here
});
  • Related