auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

How can I disable BottomNavigationBar on a specific page?

Open sh4msi opened this issue 2 years ago • 10 comments

hi, How can I disable BottomNavigationBar on a specific page? (Nested Routes)

sh4msi avatar Oct 03 '21 12:10 sh4msi

@sh4msi
try doing something like this before rendering your bottom nav

bool renderNavBar = true;
 if(context.topRouteMatch.name == MyFullScreenPage.name){
   renderNavBar = false;
 }

Milad-Akarie avatar Oct 03 '21 12:10 Milad-Akarie

Hey @Milad-Akarie , i have follow-up question here regarding this. I have complex nested routes tree with multiple routers inside tabsRouter. For some pages inside nested tree want to show bottom navigation and for some want to hide. To able to achieve this don't want to write every page name to function like above. Can we have option like fullScreenDialog to be defined on generated routes so i can add my state management to decide bottom navigation or not regarding that option?

SelcukKomurcu avatar Oct 03 '21 15:10 SelcukKomurcu

Hello, I've actually been working on something that can help with this, it will probably be shipped with the next release. The whole idea is being able to pass meta/extra data to the route annotation and have it passed to the generated route configs.

  AutoRoute(
   path: ':id',
   page: BookDetailsPage,
   meta: {'hideBottomNav': true},
  ),

and you check for the flag in ui like

 final hideBottomNav = context.topRouteMatch.meta['hideBottomNav'] == true;

Milad-Akarie avatar Oct 04 '21 07:10 Milad-Akarie

Awesome! That's what i needed, thanks.

SelcukKomurcu avatar Oct 04 '21 12:10 SelcukKomurcu

@sh4msi try doing something like this before rendering your bottom nav

bool renderNavBar = true;
 if(context.topRouteMatch.name == MyFullScreenPage.name){
   renderNavBar = false;
 }

If there are multiple routes that doesn't need the bottom-navigation-bar, we can also just use an array.contains like this....

final routesNoBottomBar = [MyPage2.name,MyPage3.name,MyPage4.name]
 if( routesNoBottomBar.contains(  context.topRouteMatch.name )  ){
    renderNavBar = false;
  }

I prefer this one bacause this is more centralized rather implementing meta stuff scattered everywhere

Dionnie123 avatar Oct 15 '21 11:10 Dionnie123

hello, where to put this if statement? I'm putting it inside bottomNavigationBuilder of AutoTabsScaffold and between page navigation it does not invoke this method, therefore the check is not executed.

yevyevyev avatar Oct 16 '21 19:10 yevyevyev

Salam! Is there any progress on this?

Hello, I've actually been working on something that can help with this, it will probably be shipped with the next release. The whole idea is being able to pass meta/extra data to the route annotation and have it passed to the generated route configs.

  AutoRoute(
   path: ':id',
   page: BookDetailsPage,
   meta: {'hideBottomNav': true},
  ),

and you check for the flag in ui like

 final hideBottomNav = context.topRouteMatch.meta['hideBottomNav'] == true;

madatr avatar Feb 19 '22 07:02 madatr

Hello, I've actually been working on something that can help with this, it will probably be shipped with the next release. The whole idea is being able to pass meta/extra data to the route annotation and have it passed to the generated route configs.

  AutoRoute(
   path: ':id',
   page: BookDetailsPage,
   meta: {'hideBottomNav': true},
  ),

and you check for the flag in ui like

 final hideBottomNav = context.topRouteMatch.meta['hideBottomNav'] == true;

Any progress on this?

tahaaslam1 avatar May 26 '22 17:05 tahaaslam1

Hello, I've actually been working on something that can help with this, it will probably be shipped with the next release. The whole idea is being able to pass meta/extra data to the route annotation and have it passed to the generated route configs.

  AutoRoute(
   path: ':id',
   page: BookDetailsPage,
   meta: {'hideBottomNav': true},
  ),

and you check for the flag in ui like

 final hideBottomNav = context.topRouteMatch.meta['hideBottomNav'] == true;

Hi, Is there any Update on this? @Milad-Akarie

hussain-abbas-06228 avatar Jun 20 '22 13:06 hussain-abbas-06228

İt's already done

Milad-Akarie avatar Jun 20 '22 13:06 Milad-Akarie

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Aug 20 '22 08:08 github-actions[bot]