Integrating Bottom Navigation with Go Router in Flutter

Setting Up Go Router in Flutter
- Add the Go Router package to the Flutter project.
- Define routes by associating a string with a page builder.
- Initialize the Go Router with the routes.
Using a Singleton Helper Class
- Create a Singleton class called CustomNavigationHelper.
- Add a method called getPage to wrap the routes in a MaterialPageRoute.
- Utilize the CustomNavigationHelper in the main app widget to set up the application with the Go Router.
The Role of PageBuilder in StatefulShellBranch's Routes
- The PageBuilder in each StatefulShellBranch's routes defines the UI for each individual route within the branch.
- It serves as a shell to host the bottom navigation interface, while the StatefulShellBranch handles the individual pages in each tab's navigation stack.
How BottomNavigationPage and Go Router Work Together
- BottomNavigationPage is the UI shell that contains the navigation state for the individual branches (tabs) managed by the Go Router.
- When a tab is tapped, the onTap method of the BottomNavigationBar is called, which manages the state of the bottom navigation.
The BottomNavigationPage as a UI Shell
- The BottomNavigationPage acts as the shell and controller for switching between different tabs.
- It receives a child widget from the StatefulShellBranch, which contains the current page based on the active tab.