I have a code like this:
name = FirebaseFirestore.instance.collection("users").doc("${FirebaseAuth.instance.currentUser?.uid}").get().then((value) => value.data()!["name"]).toString();
I get the following output from this code:
Instance of 'Future <dynamic>'
How can I resolve this error?
Thanks for help.
CodePudding user response:
You have to add await
to Future
to get the returned value.
var snapshot = await FirebaseFirestore.instance.collection("users").doc("${FirebaseAuth.instance.currentUser?.uid}").get();
if(snapshot.data!=null){
name=snapshot.data!['name'];
}
CodePudding user response:
The 'name' is already in a string, you don't need to use toString() Try removing that.