Firebase 如何在textfield-flatterweb中设置错误消息
我正在Flitter中构建我的web应用程序的注册屏幕,我正在使用firebase auth注册用户。如果firebase返回任何错误,我想在textfield中设置错误消息 这是我的密码Firebase 如何在textfield-flatterweb中设置错误消息,firebase,flutter,firebase-authentication,textfield,flutter-web,Firebase,Flutter,Firebase Authentication,Textfield,Flutter Web,我正在Flitter中构建我的web应用程序的注册屏幕,我正在使用firebase auth注册用户。如果firebase返回任何错误,我想在textfield中设置错误消息 这是我的密码 Form( key: _formKey, child: Column( children: [ TextFormField( onChanged: (value) { name = value;
Form(
key: _formKey,
child: Column(
children: [
TextFormField(
onChanged: (value) {
name = value;
},
),
TextFormField(
onChanged: (value) {
email = value;
},
),
TextFormField(
onChanged: (value) {
password = value;
},
),
Container(
child: ElevatedButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
try {
UserCredential userCredential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(email: email, password: password);
} on FirebaseAuthException catch (e) {
print(e.code.toString());
} catch (e) {
print(e);
print(e.toString());
}
}
},
child: Text('Create an Account'),
),
),
],
),
),
我建议查看官方文件中的指南: