mt-akar / bottom_nav_layout

A quick and powerful Flutter layout with a bottom navbar.
https://pub.dev/packages/bottom_nav_layout
MIT License
35 stars 11 forks source link

Can the bottom bar persist? #1

Closed mark8044 closed 3 years ago

mark8044 commented 3 years ago

First off all, the package looks great so far.

One key requirement some (myself included) may have: Persistent bar.

We want our bottom navigation bar to always show, no matter what page is navigated to. currently, a new page will cover the bottom navigation bar.

Can it somehow optionally be programmed to maintain the bottom nav bar at all times?

mark8044 commented 3 years ago

Wait, I think reading your documentation I figured it out, is this correct? It seems to be working for me atleast

    return BottomNavLayout(
      // The app's destinations
      pages: [
            (navKey) => Navigator(
                          key: navKey,
                          initialRoute: "/",
                          onGenerateRoute: (routeSettings) => MaterialPageRoute(
                            builder: (context) {
                         return NewsScreen();
                            },
                          ),
                         ),
            (navKey) => Navigator(
                          key: navKey,
                          initialRoute: "/",
                          onGenerateRoute: (routeSettings) => MaterialPageRoute(
                            builder: (context) {
                              return TextbookScreen();
                            },
                          ),
                        ),
            (navKey) => Navigator(
                          key: navKey,
                          initialRoute: "/",
                          onGenerateRoute: (routeSettings) => MaterialPageRoute(
                            builder: (context) {
                              return ArticleScreen();
                            },
                          ),
                        ),
      ],
mt-akar commented 3 years ago

You figured it out yourself.

If the Navigator you are pushing to is above the BottomNavLayout in the widget tree, it will replace the entire widget tree below the navigator, resulting in the bottom navigator being gone.

Solution is to wrap your pages with a Navigator as @mark8044 showed or as shown in the documentation.