PersistentBottomNavBar
PersistentBottomNavBar copied to clipboard
How to force jumptotab in each build of PersistentTabView?
I have the PersistentTabView setup in provider condition, eg:
Widget build(BuildContext context) => Consumer<ProviderSample>(
builder: (_, condition, __) {
_controller!.jumpToTab(1); // adding this wont make the tab to force to jump tab
_controller!.index = 1; //neither did this.
return PersistentTabView(
controller: _controller,
screens: (condition) ? _buildScreens() : _buildScreens2(),
items: (condition) ? _navBarsItems() : _navBarsItems2(),
....
});
Screens buildScreen() - has 5 screens buildScreen2() - has 2 screens
Items _navBarsItems() - has 5 items _navBarsItems2() - has 2 items
when the user is in condition true, _navBarsItems has 5, and if he is in 4th index of screen, the build seems to ignore _controller!.index = 1; and try to access _controller!.index = 3 (4th screen) anyway and error out of range is thrown.