Gba*_*iwo 2 firebase firebase-authentication flutter
我的注册页面有以下字段名称、密码、确认密码和电子邮件,但似乎 flutter firebase 仅适用于电子邮件和密码。如何使更多字段在以下代码中工作:
createUser()async{
if (checkFields()){
await FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password)
.then((user){
print('signed in as ${user.uid}');
Navigator.push(context, MaterialPageRoute(builder: (context)=> (Usertype())));
}).catchError((e){
print(e);
});
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,您不能让 FirebaseNames在注册事件中接受。但您可以在注册后更新用户信息。
updateProfile认证成功后的使用方法。您可以将其作为 Android 示例进行检查,此处作为 Flutter 包中的方法。
在你的情况下,
createUser()async{
if (checkFields()){
await FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password)
.then((user){
print('signed in as ${user.uid}');
var userUpdateInfo = new UserUpdateInfo(); //create user update object
userUpdateInfo.displayName = name; //set user display name to your variable.
await firebaseAuth.updateProfile(userUpdateInfo); //update the info
await user.reload(); //reload the user data
Navigator.push(context, MaterialPageRoute(builder: (context)=> (Usertype())));
}).catchError((e){
print(e);
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1769 次 |
| 最近记录: |