Flutter Stream Builder does not update screen

48 Views Asked by At

I am facing a problem in redirecting user to dashbaord screen after login or register. Here is scenerio with I am having issue.

Screen A has two button Login & Register.

As I click any of the button I navigate through navigator push function. Here if I login it does not redirect me to dashboard.

Instead if I discard the Screen A and use direct Login screen, I got successfully loggedin.

This may be because I am not on the same try but what is best solution on this. I have another solution if I use PushReplacement with my root app. However, that allow me to login but after my click on login button to viewing the dashboard I got a glimpse of splash screen it seems like the whole loading process is running again that is not good practice.

Please suggest anything on this.

1

There are 1 best solutions below

0
Praween Kumar On

// In MaterialApp Initial Page Call

Splash();

// In the Splash screen after completing the timer

Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => LoginScreen()), );

// In the Login Screen before login

Navigator.push( context, MaterialPageRoute(builder: (context) => RegisterScreen()), );

// In Register Screen before login

Navigator.pop(context); // Back to login screen

// In Login Screen after successful login

Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => DashboardScreen()), );