在我的Firebase身份验证中,我遇到错误:
错误:参数类型'Null Function(FirebaseUser)'不能为 分配给参数类型'FutureOr 函数(AuthResult)”。 (argument_type_not_assignable位于 [认证] lib \ loginpage.dart:44)
如果importfirebase_auth和flutter材质
onPressed: (){
FirebaseAuth
.instance
.signInWithEmailAndPassword(
email: _email,
password: _password
).then((FirebaseUser user){
Navigator.of(context).pushReplacementNamed('/homepage');
})
.catchError((e){
print(e);
});
}
答案 0 :(得分:1)
查看插件的源代码功能
$scope.treeData.view()
是一个Future,它返回AuthResult,所以问题出在您的回调方法中
.signInWithEmailAndPassword()
应改为
.then((FirebaseUser user)
您可以看到它here
答案 1 :(得分:0)
onPressed: () {
FirebaseAuth.instance
.signInWithEmailAndPassword(
email: _email, password: _password)
.then((value) {
Navigator.of(context).pushReplacementNamed('/homepage');
}).catchError((e) {
print(e);
});
},
尝试一下,它将起作用。如果您有multidex错误,请参考此链接 https://developer.android.com/studio/build/multidex#java