Episode 4 - Create An App State Manager
Before we move on adding the Navigator 2.0 to our app. We need to add some files. Let us get started. Create a new directory in our lib folder named router. This will hold all the classes and files that we will create in our project. Create a new file as book_pages.dart. This will have a list of unique keys for each page. This will help us when we will call the unique pages key while navigation.
We need to add few of the plugins that we will be needing throughout our project. Navigate to our pubspec.yaml file and add the latest versions of the following plugings. We will be using the provider to manage the state of our application and url_strategy to compile our app with the web url. The versions may be different bu as far as they are above the current version you should be fine to go ahead.
In our routes folder create a new dart file named ‘app_state_manager.dart’. In this file we will creating a manager that will manage the state of our application throughout the app. Create an AppStateManager class that extends ChangeNotifier so that our state managert notifies the router for the changes that takes place in our app. Let us define few of the boolear variable with false value, that holds the App States which we feel our app will be having. We can always add extra app states on later. Creating the getter methods of the private varibles that we have defined so that these can accessible from the outside of our class.