flutter中的火箱请求避免,然后阻止
我正在尝试从Firebase中收到当前登录的用户的用户名,以在Appbar中显示名称。我目前正在使用FutureBuilder进行此操作,该方法将以下方法作为未来:
_getUser() async {
print("we are inside!!!");
await FirebaseFirestore.instance
.collection('users')
.where("user_id", isEqualTo: FirebaseAuth.instance.currentUser!.uid)
.snapshots()
.first
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
this._userName = doc["user_name"];
print("we found username: " + _userName);
});
});
await Future.delayed(Duration(seconds: 1));
print("i bims hier rein");
return this._memoizer.runOnce(() async {
return _userName;
});
}
到目前为止效果很好:我为新用户添加了某种教程(package:tutorial_coach_mark)。当在教程中登录的新用户出现并在教程开始后,应用程序启动,但是用户的名称并未通过上面显示的方法收到。
当用户是旧用户并且教程未显示时,将收到名称。
提前致谢!
I am trying to recieve the username of the currently logged in user from firebase, to show the name in the appbar. I am currently doing this with a FutureBuilder, which got the following method as future:
_getUser() async {
print("we are inside!!!");
await FirebaseFirestore.instance
.collection('users')
.where("user_id", isEqualTo: FirebaseAuth.instance.currentUser!.uid)
.snapshots()
.first
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
this._userName = doc["user_name"];
print("we found username: " + _userName);
});
});
await Future.delayed(Duration(seconds: 1));
print("i bims hier rein");
return this._memoizer.runOnce(() async {
return _userName;
});
}
That worked perfectly fine until now: I added some kind of tutorial for new users (package: tutorial_coach_mark). When a new user logged in the tutorial shows up and after the tutorial the app starts, but the name of the user isn't recieved by the method shown above.
When the user is a old user and the tutorial does not show, the name is recieved.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论