【发布时间】:2020-12-05 21:52:34
【问题描述】:
我将不同用户的数据保存在他们的 uid 节点中,并且在 uid 节点中我生成了不同的密钥来保存数据。我试图从键节点检索电子邮件、用户名。 我尝试使用以下代码获取电子邮件、用户名:- `
@override
void initState() {
super.initState();
getCurrentUser();
rootRef.child('Manager').child(loggedInUser.uid).child(accountKey);
rootRef.once().then((DataSnapshot snap) {
var value= snap.value;
print(value['username']);
}
);
}
` 但我得到一个空值。 我如何检索电子邮件、用户名并将其显示到文本小部件。
【问题讨论】:
-
你试过 rootRef.child('Manager').child(loggedInUser.uid).child(accountKey).once().then((DataSnapshot snap) { var value= snap.value;打印(值['用户名']);});
-
是的,我试过了,但它不起作用
标签: firebase flutter dart firebase-realtime-database firebase-authentication