在我的 Firebase 身份验证中,我遇到了错误:
error: The argument type 'Null Function(FirebaseUser)' can't be assigned to the parameter type 'FutureOr Function(AuthResult)'. (argument_type_not_assignable at [authentication] lib\loginpage.dart:44)
如果导入 firebase_auth 和 flutter Material
onPressed: (){
FirebaseAuth
.instance
.signInWithEmailAndPassword(
email: _email,
password: _password
).then((FirebaseUser user){
Navigator.of(context).pushReplacementNamed('/homepage');
})
.catchError((e){
print(e);
});
}
最佳答案
查看插件源码函数
.signInWithEmailAndPassword()
是一个返回 AuthResult 的 Future,所以问题出在你的回调方法中
.then((FirebaseUser user)
应该改为
.then((AuthResult auth)
可以看到here
关于android - Flutter Firebase Error Null fundtion(FirebaseUser)无法分配给参数,仪表类型 FutureOr <dynamic>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57411112/