Episode 13 - Navigate to Home Page
We have to show the HomeScreens from two routes 1st when users SignUps for the first time we take the user to the HomeScreen and 2nd route when the user Logins that time we show the homeScreen. So First let us create these two function in the LoginIn Screen and SignUp Screen.
Navigate to LoginScreen and in the onPressed anonymous function let us call the login function that we have written in our appStateManager.
Provider.of<AppStateManager>(context, listen: false).login('Anyusername', 'anypassword');
Now open the BookRouterDelegate and add the following condition to navigate to HomeScreen.
if(appStateManager.isLoggedIn) HomeScreen.page(),
Reload the app and now press the login button on the login page and you will be taken to homePage.
Navigate to Sign Up Screen and in the SignUp button anonymous function let us call the onSignUpCompleted() function from our appStateManager
Provider.of<AppStateManager>(context, listen: false).onSignUpCompleted();
Reload the app and check by clicing the signup button you will notice that nothing happens that is cause we have not changed the condition that we have written in pages to display our homepage.
if (appStateManager.isLoggedIn || !appStateManager.isSignUp && appStateManager.onSignUpComplete) HomeScreen.page(),
Here We check first if our isLogged is true or we check if the onSignUpComplete is true. If any of the two conditions is true then we want to display the homePage. Now reload the App and press the SignUp button and you will notice that home page is displayed. reload the app and check if the login button works as well.