1

I have added this collection:

Map<String, String> userDataMap = {
              "userName": usernameEditingController.text,
              "userEmail": emailEditingController.text,
              "account": userType  // there is premium and regular account type
            };

...

Future<void> addUserInfo(userData) async {
    Firestore.instance.collection("users").add(userData).catchError((e) {
      print(e.toString());
    });
  }

And actually I don't know how to get info about account type, I would like to print/get value assigned to "account".

This is what I tried but it did nothing:

var ok = await Firestore.instance
              .collection('users')
              .where('email', isEqualTo: email)
              .getDocuments();
          print(ok);

Thank you in advance.

1 Answer 1

0

Inside the document, you have a field called userEmail and not email therefore you need to do the following:

var userDoc = await Firestore.instance
              .collection('users')
              .where('userEmail', isEqualTo: email)
              .getDocuments();
userDoc.documents.forEach((result) {
      print(result.data["account"]);
    });
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.