PlatformException (ERROR_INVALID_EMAIL, адрес электронной почты неправильно отформатирован., Нулевой) - PullRequest
0 голосов
/ 19 апреля 2020

Я работаю в проекте и использую Firebase для аутентификации, поэтому, когда я запустил код, он возвращает сообщение об ошибке (PlatformException (ERROR_INVALID_EMAIL, адрес электронной почты неверно отформатирован., Ноль)) вот мой код: нужен ваш помогите решить проблему.



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);
                }
           ```

1 Ответ

0 голосов
/ 19 апреля 2020

Ошибка, на которую вы ссылаетесь, связана с тем, как правильно ввести email address.

: youremail@example.com

, например: test@gmail.com

...