Issue
I am trying this -
final Future<FirebaseUser> user = auth.currentUser();
but the problem is that instead of making a document by the "userid" it is making a document by the name of -
Instance of 'Future<FirebaseUser>'
This is literally my documents name right now, but I want to make it the userid specifically.
What should I do?
Solution
Update (2020.09.09)
After firebase_auth version 0.18.0
Few breaking updates were made in firebase_auth 0.18.0. FirebaseUser is now called User, currentUser is a getter, and currentUser is synchronous.
This makes the code for getting uid like this:
final FirebaseAuth auth = FirebaseAuth.instance;
void inputData() {
final User user = auth.currentUser;
final uid = user.uid;
// here you write the codes to input the data into firestore
}
Before firebase_auth version 0.18.0
uid is a property of FirebaseUser object. Since auth.currentUser() return a future, you have to await in order to get the user object like this:
final FirebaseAuth auth = FirebaseAuth.instance;
Future<void> inputData() async {
final FirebaseUser user = await auth.currentUser();
final uid = user.uid;
// here you write the codes to input the data into firestore
}
Answered By - dshukertjr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.