This is my method i intend to use it to fetch data from database to a Text widget
getSnapshotData (String child){
final User _firebaseUser = firebaseAuth.currentUser;
databaseReference
.child("users")
.child(_firebaseUser.uid)
.once()
.then((DataSnapshot dataSnapshot) {
return dataSnapshot.value('${child}');
}
);
this is my Text widget to retrieve name from the database
Text(
'Hi,' + ' ${getSnapshotData('name')}',
style: TextStyle(
color: Colors.black,
fontSize: 32,
)),
this is my Text widget to retrieve order count from the database
Text(
getSnapshotData('orders_count').toString(),
style: TextStyle(
color: Colors.black,
fontSize: 32,
)),
i have tried logging the values of orders count and name and virtually everything,
Everything seems to be ok i dont understand whats the problem i used more than three hours trying to look for a solution but failed
