Search code examples
firebaseflutterdartgoogle-cloud-firestoredata-retrieval

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


Solution

  • 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