jb3rndt / PersistentBottomNavBarV2

A highly customizable persistent bottom navigation bar for Flutter
https://pub.dev/packages/persistent_bottom_nav_bar_v2
BSD 3-Clause "New" or "Revised" License
49 stars 54 forks source link

Navbar disappear #92

Closed o3web closed 1 year ago

o3web commented 1 year ago

Hi,

I've an issue with the PersistentBottomNavBar. When i push a new screen by click on a Dialog "ok" button. The nav bar disappear on the new screen event if i put "withNavBar: true" .

Here is the code i using to redirect after the API return 200 response. My onPressed environement is async to allow the JSON return.

PersistentNavBarNavigator.pushNewScreen( context, screen: const contactsHome(), withNavBar: true, pageTransitionAnimation: PageTransitionAnimation.cupertino, )

Do you think is due to the "async" onPressed ?

Regards,

jb3rndt commented 1 year ago

From what you described there is one flow of pushing your dialog and screen that could lead to this problem: If your Dialog is pushed to the root Navigator (by using showDialog(..., rootnNavigator: true);), then the context inside your Dialog can only use this root navigator, no matter what you do. So at the moment you want to push your contactsHome screen, you are using a context that cant contain the navigator of the current PersistentBottomNavBar tab (every tab of your navbar creates its own navigator to provide parallel navigation stacks that dont overwrite each other), thus any call of pushNewScreen wont contain the navbar. To solve that you have two options:

  1. use showDialog(rootNavigator: false)
  2. in the function where you use showDialog, await the showDialog and push your new screen after the dialog was dismissed