'Persistent Bottom Nav Bar, How can I use that in another page that is not included in bottom navigation bar screens?

I am using persistent_bottom_nav_bar 4.0.2 for implement bottom navigation bar though out the app. It actually works fine with bottom navigation bar items and related screens. Id there any way that I can use this navigation bar in another page that is not related to screens mention in bottom bar.

   @override
   Widget build(BuildContext context) {
     return PersistentTabView(
       context,
       controller: _controller,
       screens: _buildScreens(),
       items: _navBarsItems(),,
       navBarStyle: NavBarStyle.style3, // Choose the nav bar style with this property.
    );
  }

  List<Widget> _buildScreens() {
    return [
      DashboardScreenV2(),
      Menu()
    ];
  }
  List<PersistentBottomNavBarItem> _navBarsItems() {
    return [
      PersistentBottomNavBarItem(
         icon: Icon(CupertinoIcons.home),
      ),
      PersistentBottomNavBarItem(
         icon: Icon(CupertinoIcons.search),
      ),
   ];
  }

as in the above code when user click on home and search it' s working fine imagine if there is page called profile how can I use this bottom bar in that page without adding it to bottom bar item.



Solution 1:[1]

You probably found out, but someone is gonna need this. You can use routeAndNavigatorSettings property like this:

 PersistentBottomNavBarItem(
    icon: Icon(CupertinoIcons.cube_box_fill),
    title: ("Achats"),
    routeAndNavigatorSettings: RouteAndNavigatorSettings(
      onGenerateRoute: (RouteSettings settings) {
        WidgetBuilder builder;
        // Manage your route names here
        switch (settings.name) {
          case '/profile':
            builder = (BuildContext context) => Profile();
            break;
          default:
            throw Exception('Invalid route: ${settings.name}');
        }
        return MaterialPageRoute(
          builder: builder,
          settings: settings,
        );
      },
    ),
    activeColorPrimary: appMainColor(),
    inactiveColorPrimary: appMainColor(),
  )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ousow37