flutter - 使用 Flutter 进行 Firebase 身份验证
问题描述
Flutter Android Firebase authentication Error, The Authentication pass through but error in the terminal 虽然应用程序没有失败
[错误:flutter/lib/ui/ui_dart_state.cc(148)] 未处理的异常:NoSuchMethodError:在 null 上调用了 getter 'uid'。
错误似乎来自这行代码
Future<String> currentUser() async {
FirebaseUser user = await _firebaseAuth.currentUser();
return user.uid;
}
解决方案
的结果_firebaseAuth.currentUser()
为空。通常这意味着您根本没有登录。
在访问当前用户之前,请确保您已登录。例如使用电子邮件凭据:
await _firebaseAuth.signInWithEmailAndPassword(email:'email@here.com', password: 'abc123');
好消息是firebase包会缓存当前用户,所以在你登录后你暂时不用再做一次,你可以简单地调用你的currentUser
方法。
推荐阅读
- php - 向数据库插入未知数量的输入
- aurelia - 如何在 aurelia 商店中存储导航?
- excel - 跳过空白单元格并完成的宏(发送电子邮件的按钮)
- pandas - 带有多个分隔符的 pandas read_csv 不起作用
- emacs - 让 npm 在守护进程模式下使用 spacemacs
- python - Python,matplotlib。在两点之间绘制函数
- angular - 如何获得服务器端分页但客户端排序
- c# - 如何创建word等水晶报表多栏
- ios - Swift - Bonjour NSNetServiceBrowser 的对等限制是否大于 MCSession 的 8?
- javascript - 简单警报警报消息仅在屏幕上闪烁