Flutter [firebase_auth] onAuthStateChanged stoped listening

Viewed 173

onAuthStateChanged no longer listens to changes, so basically, when I create a new account or sign in to an existing one, it's stuck in the loading spinner but the user did create it in the firebase users. I'm using StreamBuilder:

   home:StreamBuilder(
            stream: FirebaseAuth.instance.authStateChanges(),
              builder: (ctx, userSnapshot) {
              if (userSnapshot.hasData) {
                return SellerScreen(docsRef);
              }
              return AuthScreen();
            },
          ),

what I get in the console:

D/FirebaseAuth( 9477): Notifying id token listeners about user ( VQghDgOucFdCcWLdPlCJNTd5eO72 ).
D/FirebaseAuth( 9477): Notifying auth state listeners about user ( VQghDgOucFdCcWLdPlCJNTd5eO72 ).
1 Answers

The code in the console stipulates that the user has either been created or signed in.

Your problem might be with where your spinner widget is located in the code... Can i have a snippet on that to see if I can help?

...in any case, what i usually do is:

bool loading = false;
@override
Widget build(BuildContext context) {
    return loading ? Loading() : HomeScreen();
}

With this, I've told flutter to show the loading screen while the user is being created or signed in. The bool type loading is just to toggle between the true and false state of the loading widget

Related