How to search for user data and retrieve them from firebase with flutter?
1,518
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
![omar developer](https://lh4.googleusercontent.com/-VjuOSd2EjEQ/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucm7l9ySokutDmonMub7gJicRzJ8oA/photo.jpg?sz=256)
Author by
omar developer
Updated on December 21, 2022Comments
-
omar developer over 1 year
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?
-
omar developer about 4 yearsassumbtion = true :)
-
omar developer about 4 yearsBut How can I get the email or the password after and store it in a const
-
Peter Haddad about 4 years
value.data
will contain the email and password, you can dovalue.data["email"]
andvalue.data[password"]
-
omar developer about 4 yearsabout storing it
-
Peter Haddad about 4 yearsstore it to an instance variable and cal setState
-
omar developer about 4 yearsIt's Ok now , Sorry false alarm.
-
omar developer about 4 yearsCan I change thw way to search for the document by replacing 'firebase.uid' with any thing else right
-
Peter Haddad about 4 yearsif u have uid as a document id, then you need to use the above in the answer
-
omar developer about 4 yearswhat about searching by the username that the user entered, Is it possible?
-
omar developer about 4 yearsLike storing the value of username in a controller and put the controller in firebase.uid
-
Peter Haddad about 4 years
-
omar developer about 4 yearsWhat is a query?
-
omar developer about 4 yearsU seem like a smart guy :)