Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to directly Send User to HomePage after SignIn (Signup) is successful- flutter firebase

Here is my Code

RoundedElevatedButton(
        child: const Text("Sign in"),
        onPress: () async {
          try {
            await   FirebaseAuth.instance
                .signInWithEmailAndPassword(email: email, password: password);

          } catch (e) {
            print(e.runtimeType);
          }
        });

I want To send the user to the homepage directly after login succeeds

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Modify the onPress function as follows:

 onPress: () async {
          try {
            final user = await   FirebaseAuth.instance
                .signInWithEmailAndPassword(email: email, password: password);
            
            if(user!=null){
                Navigator.of(context).pushNamed('/home'); //Navigate to home screen.
            }

          } catch (e) {
            print(e.runtimeType);
          }
        }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading