Flutter Navigator 2.0

Nov 8 2022 · Dart 2.17.3, Flutter 3.0.2, Android Studio 2020.3

Part 2: Deep Dive Into Navigator 2.0

04. Create an App State Manager

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 03. What are we Going to Build Next episode: 05. Create App State Notifier Functions

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.

Learn more Already a subscriber? Sign in.

Transcript: 04. Create an App State Manager

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.