[英]How to sign up and in with OAuth credentials in firebase and flutter?
[英]How to make Flutter sign up with more fields?
我的注册页面包含以下字段:名称,密码,确认密码和电子邮件,但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);
});
}
}
不幸的是,您不能使Firebase在注册事件时接受Names
。 但是,您可以在注册后更新用户信息。
身份验证成功完成后,请使用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);
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.