Previous episode: 04. Create an App State Manager
Next episode: 06. Create a Book Manager Class
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In our abstract manager we have created some private variables in our previous video. If you'll see these variables are throwing some warning. This warning is because we haven't used our variables so let us create some functions in which we will use our variables. So in our abstract manager class, we are going to create few functions which will change the value of our predefined variables to true and then notify the changes to our change notifier. The first function that we are going to create is called as initialized app. In this function we are calling a timer which has a duration of two seconds, and after the two seconds we are setting the initialized value to true. We are adding a timer of two seconds so that we will get a real feel of initializing our application. After setting the initialized value to true we are notifying the listeners let us create two functions login and logout. The login function will have two string parameter, username and password. We won't be needing this parameter as we won't have any login functions, but it's for users who want to pass username and password to create a login function. In our login function, we are setting the value to true and then we are notifying the listener. Just like the login function. Let us also create a logout function which will help the users to log out from our application. In our logout function, we are going to set all the values to false and we will re initialize our application. So we have set is logged in to false on signup complete to false and initialized to false. After that, we are re initializing the application so that after logging out the user, our application gets back to our login screen and then we are notifying the listeners so that the change in this value is observed by our provider. If you will scroll up. You can see now the initialized and logged in function are not showing any warnings because we have used them in our class. Let us also create some functions which will use the following variables that we have created. The next function that we create is on cart tapped. This function will be called When the user taps on a cart. In this function we pass a bullion value and we make sure that the variable on cart is updated by the bullion value that we are passing as A parameter. And then we are notifying the listeners again let us create one more variable called As on settings Tab. This will be called When the user taps on the setting icon in the App bar. In this function we are also passing a bullion value which we can pass dynamically when we call the function. And then we are setting the On Setting variable to the value that we are passing through the parameter. Also, we're going to set the Notify Listeners so we come to know that the value has been changed. If you scroll up, you can see that some variables are still showing some warnings because they aren't used yet. Now it's time for your first challenge. Create the functions in which you can use this variables so that the warning will go pause this video and create the functions like we have created before. I hope you were able to create the functions that we required, but if you get stuck you can carry on with this video. So the next function that we need is wide Checkout Tab. This function is called When the User Taps on the Checkout Button. In this function you're going to set develop dynamically that we pass into our parameter and then we update the Notify Listener. You also create one more function called As on my Booked tap. This function will be called When the User presses on the button my booked tab. And we're going to update the value of this variable dynamically as well. We also going to create one more function called As on Read Booked tab. This function will be called When the User Taps or presses on the button or Read Book. And we are going to set the value dynamically to the variable on Read Book. And at last we're going to create a final function in this class called As on Sign Up Tap. This function will set the value of is signup to the value that we are passing and we are going to update the values by Notify Listeners. After calling these functions from our provider we will be able to change the state of our application. I hope you are able to complete this first challenge that we had and also understand how the app State Manager works.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.