我在一个项目中工作并使用 Firebase 进行身份验证,所以当我运行代码时,它返回一个名为(PlatformException(ERROR_INVALID_EMAIL,电子邮件地址格式错误。,null))的错误,这是我的代码:需要你的帮助来解决问题。
class _RegistrationScreenState extends State<RegistrationScreen> {
final _auth = FirebaseAuth.instance;
String email;
String password;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Hero(
tag: 'logo',
child: Container(
height: 200.0,
child: Image.asset('images/logo.png'),
),
),
SizedBox(
height: 48.0,
),
TextField(
keyboardType: TextInputType.emailAddress,
textAlign: TextAlign.center,
onChanged: (value) {
email = value;
},
decoration: kMessageTextFieldDecoration.copyWith(
hintText: 'Enter your email'),
),
SizedBox(
height: 8.0,
),
TextField(
obscureText: true,
textAlign: TextAlign.center,
onChanged: (value) {
password = value;
},
decoration: kMessageTextFieldDecoration.copyWith(
hintText: 'Enter your password'),
),
SizedBox(
height: 24.0,
),
RoundedButtons(
colour: Colors.blueAccent,
text: 'Register',
onPressed: () async {
try {
final newUser = await _auth.createUserWithEmailAndPassword(
email: email, password: password);
if (newUser != null) {
Navigator.pushNamed(context, ChatScreen.id);
}
} catch (e) {
print(e);
}
```