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
47 stars 48 forks source link

Is there a possibility to maintain state only of one tab? #170

Closed kawi15 closed 3 weeks ago

kawi15 commented 4 weeks ago

I need to maintain state of one tab, when not really for all the others.

Is there possibility to do that with this package or there is any possible workaround?

I am using BlocConsumer under this tab, but when I set stateManagement to false it's refreshing every time I open it.

jb3rndt commented 3 weeks ago

You can try to use the onTabChanged callback on PersistentTabView to pop all screens on each tab that should not have state. If you really need to rebuild the StatefulWidget of the screen in each tab that should not maintain state, I dont think this package can offer you something so you need to find a solution in the flutter framework itself.

kawi15 commented 3 weeks ago

Can you post sample code how it should look like with onTabChanged? I tried to use Navigator.of(context).popUntil((route) => route.isFirst); but it didn't work.

kawi15 commented 3 weeks ago

Ok, that was context issue. I changed it to selectedTabContext and it is working, thanks for suggestion.