Вход в Flutter с возвратом из firebase ERROR_INVALID_EMAIL - PullRequest
0 голосов
/ 06 февраля 2020

Я получаю ERROR_INVALID_EMAIL, когда пытаюсь войти в firebase, но если я заменил _email и _password на реальную электронную почту и перешел из firebase, я получаю Log In FirebaseUser (экземпляр PlatformUser)

 import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';

class Login extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return LoginState();
  }
}

class LoginState extends State<Login> {
  final GlobalKey<FormState> formState = GlobalKey<FormState>();
  String _email;
  String _password;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text('Login Page'),
        centerTitle: true,
        backgroundColor: Colors.deepOrange,
      ),
      body: ListView(
        children: <Widget>[
          Container(
            padding: EdgeInsets.all(10),
            child: Column(
              children: <Widget>[
                Form(
                  key: formState,
                  child: Container(
                    child: Column(
                      children: <Widget>[
                        TextFormField(
                          keyboardType: TextInputType.emailAddress,
                          autofocus: false,
                          decoration: InputDecoration(
                            icon: Icon(Icons.email),
                            hintText: 'Enter Your E-mail',
                          ),
                          validator: (val) {
                            if (val.isEmpty) {
                              return 'Please Enter Your E-mail Address';
                            }
                            ;
                          },
                          onSaved: (val) {
                            _email = val;
                          },
                        ),
                        TextFormField(
                          autofocus: false,
                          obscureText: true,
                          decoration: InputDecoration(
                            icon: Icon(Icons.vpn_key),
                            hintText: 'Enter Your Password',
                          ),
                          validator: (val) {
                            if (val.isEmpty) {
                              return 'Enter Your Password';
                            } else if (val.length < 6) {
                              return 'Your Password need to be at least 6 characters';
                            }
                            ;
                          },
                          onSaved: (val) {
                            _password = val;
                          },
                        ),
                        RaisedButton(
                          child: Text('Login'),
                          onPressed: () async {
                            final formdata = formState.currentState;
                            if (formdata.validate()) {
                              final FirebaseAuth _auth = FirebaseAuth.instance;
                              formdata.save();
                              AuthResult result = await _auth.signInWithEmailAndPassword(
                                      email: _email, password: _password)
                                  .catchError((error) => print(error.code));
                              if (result != null) {
                                FirebaseUser user = result.user;
                                if (user != null) {
                                  print('Log In: $user');
                                }
                                ;
                              }
                              ;
                            }
                            ;
                          },
                          color: Colors.deepOrange,
                          textColor: Colors.white,
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

i обновил Мой вопрос Я предоставил полный код, почему я получаю сообщение о недопустимом сообщении электронной почты, если я сначала удалил строки или удалил _email _password из строки

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...