【发布时间】:2021-03-02 07:05:24
【问题描述】:
//register.dart
RaisedButton(onPressed:(){
FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email, password: password
).then((signedInUser){
UserManagement().storeNewUser(signedInUser.user, context);
}).catchError((e){
print(e);
});
} ,
child: Text('Register'),
),
//usermanagement.dart
class UserManagement{
storeNewUser(user , context){
Firestore.instance.collection('/users').add({
'email' : user.email,
'password' : user.password,
}).then((value) {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/menupage');
}).catchError((e){
print(e);
});
}
}
当我使用 signedInUser.user 时出现错误
I/flutter (21647): NoSuchMethodError: Class 'User' has no instance getter 'password'
I/flutter (21647):接收器:“用户”实例
I/flutter (21647):尝试调用:密码
当我使用 signedInUser 时出现以下错误
I/flutter (21647): NoSuchMethodError: Class 'UserCredential' 没有实例 getter 'email'。
I/flutter (21647):接收方:“UserCredential”实例
I/flutter (21647):尝试调用:电子邮件
有人请帮我解决这个问题
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore firebase-authentication