Home > database >  Flutter & Firebase : Auth disconnects when I refresh
Flutter & Firebase : Auth disconnects when I refresh

Time:09-24

I use the anonymous auth, and everything works fine but when I want to connect with email and password, as soon as I update with hot reload, I am again anonymous. What I'm doing wrong ?

Here's my main code :

Future<void> main() async {
  await auth.signInAnonymously();
  runApp(App());
}

This is what I use to login :

void login() {
    if (_loginForm.currentState!.saveAndValidate()) {
      auth.signInWithEmailAndPassword(
        email: _email.text.trim(), 
        password: _password.text.trim()
      );
    }
  }

CodePudding user response:

Looks like the problem is with your main,

Your main need to look like that:

Future<void> main() async {
  // await auth.signInAnonymously(); 
  await Firebase.initializeApp();
  runApp(App());
}

CodePudding user response:

The problem is here:

Future<void> main() async {
  await auth.signInAnonymously(); //            
  • Related