Reputation: 139
I'm having an issue with retrieving and storing single data from FirebaseDatabase. During the debugging on my watch list i get value of the snapshot as null. I need to get city name of the current user from db.
void addToFb() async {
final User user = FirebaseAuth.instance.currentUser;
final uid = user.uid;
final city = await FirebaseDatabase.instance
.reference()
.child('Users')
.equalTo(uid)
.once()
.then((DataSnapshot snapshot) {
var temp = snapshot.value.city;
return temp;
});
Just in case my database looks like this:
- Users
|- uid
||- name
...
||- city
Thanks in advance!
Upvotes: 0
Views: 77
Reputation: 1313
This is not the solution but for make your code and db structure easy,
I suggest you to use Cloud Firestore
Because you can find all types of queries in this.
Cloud Firestore dependency
Upvotes: 2