omar developer
omar developer

Reputation: 197

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

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

Upvotes: 2

Views: 2110

Answers (2)

Saffron-codes
Saffron-codes

Reputation: 188

You can use the "where" function in firestore

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

Upvotes: 0

Peter Haddad
Peter Haddad

Reputation: 80914

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

Upvotes: 1

Related Questions