geo*_*ian 8 dart firebase-authentication flutter
我将我的应用程序与 firebase 链接,但是当我尝试在应用程序中使用新用户注册时,我收到此错误:忽略标头 X-Firebase-Locale 因为其值为 null。这是身份验证屏幕代码:
class Authscreen extends StatefulWidget {
@override
Authscreenstate createState() => Authscreenstate();
}
final auth = FirebaseAuth.instance;
class Authscreenstate extends State<Authscreen> {
void submitauthform(String email, String password, String username,
bool islogin, BuildContext ctx) async {
UserCredential authres;
try {
if (islogin == true) {
authres = await auth.signInWithEmailAndPassword(
email: email, password: password);
} else {
authres = await auth.createUserWithEmailAndPassword(
email: email, password: password);
}
} on FirebaseAuthException catch (e) {
String message = "error";
if (e.code == 'weak-password') {
message = 'The password provided is too weak.';
} else if (e.code == 'email-already-in-use') {
message = 'The account already exists for that email.';
} else if (e.code == 'user-not-found') {
message = 'No user found for this email.';
} else if (e.code == 'wrong-password') {
message = 'Wrong user privded for that user';
}
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: Theme.of(ctx).errorColor,
),
);
} catch (e) {
print(e);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).accentColor,
body: Authform(submitauthform),
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8876 次 |
| 最近记录: |