Reputation: 85
I am having an issue with returning user's email in UserAccountsDrawerHeader. In the future: FirebaseStore i do get an error: Undefined name 'FirebaseDatabase'. Try correcting the name to one that is defined, or defining the name. Maybe someone has any clue why FirebaseDatabase it comes out as a fault.
Thank you in advance!
My code snippet
UserAccountsDrawerHeader(
accountEmail: FutureBuilder(
future: FirebaseStore.instance
.collection("Users")
.doc(widget.uid)
.once(),
builder: (context, AsyncSnapshot<DataSnapshot> snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data.value['email']);
} else {
return CircularProgressIndicator();
}
}),
Upvotes: 0
Views: 201
Reputation: 80934
Firebase offers two kind of database services: Realtime database and Firestore, so if you are using Firestore then you have to do the following:
FirebaseFirestore.instance
.collection("Users")
.doc(widget.uid)
.get(),
And if you are using realtime database then do:
FirebaseDatabase.instance
.reference()
.child(widget.uid),
.once()
Upvotes: 1