rameez khan
rameez khan

Reputation: 359

Filter data get from doc

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

Upvotes: 0

Views: 35

Answers (1)

Peter Obiechina
Peter Obiechina

Reputation: 2835

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
});

Upvotes: 2

Related Questions