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?
Asked
Active
Viewed 1,909 times
2

Peter Haddad
- 78,874
- 25
- 140
- 134

omar developer
- 189
- 1
- 3
- 13
2 Answers
1
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

Peter Haddad
- 78,874
- 25
- 140
- 134
-
assumbtion = true :) – omar developer Jun 22 '20 at 08:09
-
But How can I get the email or the password after and store it in a const – omar developer Jun 22 '20 at 08:10
-
`value.data` will contain the email and password, you can do `value.data["email"]` and `value.data[password"]` – Peter Haddad Jun 22 '20 at 08:11
-
about storing it – omar developer Jun 22 '20 at 08:13
-
store it to an instance variable and cal setState – Peter Haddad Jun 22 '20 at 08:15
-
It's Ok now , Sorry false alarm. – omar developer Jun 22 '20 at 08:24
-
Can I change thw way to search for the document by replacing 'firebase.uid' with any thing else right – omar developer Jun 22 '20 at 08:26
-
if u have uid as a document id, then you need to use the above in the answer – Peter Haddad Jun 22 '20 at 08:28
-
what about searching by the username that the user entered, Is it possible? – omar developer Jun 22 '20 at 08:28
-
Like storing the value of username in a controller and put the controller in firebase.uid – omar developer Jun 22 '20 at 08:29
-
https://petercoding.com/firebase/2020/04/04/using-cloud-firestore-in-flutter/ – Peter Haddad Jun 22 '20 at 08:30
-
What is a query? – omar developer Jun 22 '20 at 08:30
-
2U seem like a smart guy :) – omar developer Jun 22 '20 at 08:30
0
You can use the "where" function in firestore
FirebaseFirestore.instance
.collection('users')
.where('email', isEqualTo: your_text_controller)
.get()
.then(...);

Saffron-codes
- 158
- 1
- 9