Elias Marrero
Elias Marrero

Reputation: 197

Getting a Map from Firestore

I'm trying to get a map (and some other vars), but the map is returning a null

Here's how it looks in Firestore's: enter image description here

And here's my code:

Future<void> getUserData() async {
    final userDocs =
        await Firestore.instance.collection('users').where('uid', isEqualTo: User.uid).getDocuments();

    for (var doc in userDocs.documents) {
      User.name = doc.data['name'];
      User.email = doc.data['email'];
      User.swipedUidsMap = doc['swipedUsers']; <<<<<<<<<<<<<<<<<
      print(User.swipedUidsMap);
    }
  }

Am I doing it wrong?

Here's the definition of that Map:

static Map<String, bool> swipedMatchingUidsMap = {};

Upvotes: 1

Views: 107

Answers (1)

You forgot to get the data from the document on the line you marked. It should be: User.swipedUidsMap = doc.data['swipedUsers'];

Cheers!

Upvotes: 1

Related Questions