'User is loged/signed in but the screen does not change

I am working with Firebase authentication and lately was not able to do anything because of the following error. When I enter the user's credentials, it gets authenticated on the Firebase console, but my app's screen does not change. What's more, the following error appears in debug console.

2 I/System.out(26261): (HTTPLog)-Static: isSBSettingEnabled false I/SurfaceControl(26261): nativeRelease nativeObject s[-5476376676702711408] I/SurfaceControl(26261): nativeRelease nativeObject e[-5476376676702711408] W/System (26261): Ignoring header X-Firebase-Locale because its value was null. 2 I/System.out(26261): (HTTPLog)-Static: isSBSettingEnabled false

void authUser(
      String email, String password, String conPassword, bool isLogin) async {
    UserCredential authResult;
    setState(() {
      isLoading = true;
    });
    FocusScope.of(context).unfocus();
    try {
      if (password != conPassword && isLogin == false) {
        showDialog(
          context: context,
          builder: (_) => const AlertDialog(
            title: Text('Passwords don\'t match'),
            content: Text('Please check if your passwords match'),
          ),
        );
      }

      if (isLogin == false) {
        authResult = await firebaseAuth.createUserWithEmailAndPassword(
          email: email,
          password: password,
        );
      } else {
        authResult = await firebaseAuth.signInWithEmailAndPassword(
          email: email,
          password: password,
        );
      }

      setState(() {
        isLoading = false;
      });
    } catch (e) {
      rethrow;
    }
  }

...

TextFormField(
                  key: const ValueKey('email'),
                  keyboardType: TextInputType.emailAddress,
                  decoration: const InputDecoration(
                    label: Text('Email adress'),
                  ),
                  onSaved: (newValue) {
                    email = newValue!;
                    FocusScope.of(context).requestFocus(_passwordNode);
                  },
                ),
                TextFormField(
                  key: const ValueKey('password'),
                  focusNode: _passwordNode,
                  obscureText: true,
                  onSaved: (newValue) {
                    password = newValue!;
                    FocusScope.of(context).requestFocus(_conPasswordNode);
                  },
                  decoration: const InputDecoration(
                    label: Text('Password'),
                  ),
                ),
                if (isLogin == false)
                  TextFormField(
                    key: const ValueKey('conPassword'),
                    focusNode: _conPasswordNode,
                    obscureText: true,
                    decoration: const InputDecoration(
                      label: Text('Confirm password'),
                    ),
                    onSaved: (newValue) {
                      conPassword = newValue!;
                    },
                  ),
                Expanded(
                  child: Container(),
                ),
                widget.isLoading == true
                    ? const Center(
                        child: CircularProgressIndicator(),
                      )
                    : ButtonBar(
                        alignment: MainAxisAlignment.center,
                        children: [
                          ElevatedButton(
                            onPressed: () {
                              setState(() {
                                isLogin = !isLogin;
                              });
                            },
                            child: Text(isLogin == true ? 'SignUp' : 'Login'),
                          ),
                          ElevatedButton(
                            onPressed: _trySubmit,
                            child: const Text('Done'),
                          ),
                        ],
                      ),


   ...
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return FutureBuilder(
            future: Firebase.initializeApp(),
            builder: (context, snapshot) {
              if (snapshot.connectionState == ConnectionState.waiting) {
                return const CircularProgressIndicator();
              }
              return MultiProvider(
                providers: [
                  ChangeNotifierProvider(
                    create: (ctx) => RecipeProvider(),
                  ),
          

  ],
            child: MaterialApp ...
             home: StreamBuilder<User?>(
                  stream: FirebaseAuth.instance.authStateChanges(),
                  builder: (context, snapshot) {
                    if (snapshot.connectionState == ConnectionState.waiting) {
                      return const CircularProgressIndicator();
                    }
                    if (snapshot.hasData) {
                      return AllRecipesScreen();
                    }
                    return AuthScreen();
                  }),
              routes: {
                AllRecipesScreen.routeName: (ctx) => AllRecipesScreen(),
                RecipeDetailScreen.routeName: (ctx) => RecipeDetailScreen(),
                AddRecipeScreen.routeName: (ctx) => AddRecipeScreen(),
                AuthScreen.routeName: (ctx) => AuthScreen(),
              },
            ),
          );
        });
  }
}


Solution 1:[1]

try changing the targetedSdk to 27, hope this helps.

Solution 2:[2]

The code seems to be quite incomplete to conclude anything out of it. And as much as I know the logs that you have provided are not errors , it is just that way and are printed every-time. I don't think your main issue seems to be firebase authentication. It may be an issue of navigation(or a wrapper if you're using one).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sobin Benny
Solution 2 KaZami-Ryu