Я пытаюсь получить поле из моей базы данных пожарного магазина. Имя поля в базе данных - «dob». Вот код для этого
FirebaseUser currentUser;
@override
void initState() {
super.initState();
_loadCurrentUser();
}
void _loadCurrentUser() {
FirebaseAuth.instance.currentUser().then((FirebaseUser user) {
setState(() { // call setState to rebuild the view
this.currentUser = user;
});
});
}
Future<String> email() async {
if (currentUser != null) {
String d;
var usId = currentUser.uid;
await Firestore.instance.collection('User').document(usId).get().then((data){
d = (data.data['dob'].toString());
});
return d;
} else {
return "no current user";
}
}
@override
Widget build(BuildContext context) {
var d = email();
return Container(
child: Text('$d'??'no'),
);
}
}
После получения данных я пытаюсь отобразить его в текстовом виджете. Но единственное, что виджет Text отображает
Instance of a Future<String>
вместо dob. Я не могу найти, что я делаю неправильно!