iamshaunjp / flutter-firebase

All course files for the Flutter & Firebase tutorial playlist on The Net Ninja YouTube channel
580 stars 441 forks source link

Loading is shown forever when the login failed #10

Closed zhouhao27 closed 4 years ago

zhouhao27 commented 4 years ago

The code:

onPressed: () async {
                  if(_formKey.currentState.validate()){
                    setState(() => loading = true);
                    dynamic result = await _auth.signInWithEmailAndPassword(email, password);
                    if(result == null) {
                      setState(() {
                        loading = false;
                        error = 'Could not sign in with those credentials';
                      });
                    }
                  }
                }

The setState for loading = false is never called. Although I set the breakpoint in signInWithEmailAndPassword, it did return null. What could be the reason? Thanks.

zhouhao27 commented 4 years ago

Sorry, my own mistake.