How to search for user data and retrieve them from firebase with flutter?

Viewed 1702

I am trying to retrieve user data that I stored on firebase database and compare it to an inputed text "trying to login but with another way ;)" but when I search for examples I can't quite understand their methods of retrieving data they don't retrieve specific data but the collection, so any ideas? enter image description here

2 Answers

To get the data you need to do the following:

  void getUserData() async{
    var firebaseUser = await FirebaseAuth.instance.currentUser();
    firestoreInstance.collection("users").document(firebaseUser.uid).get().then((value){
      print(value.data);
    });
  }

Assuming you are using Firebase authentication as the document id

You can use the "where" function in firestore

FirebaseFirestore.instance
.collection('users')
.where('email', isEqualTo: your_text_controller)
.get()
.then(...);
Related