You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using AutoTabsRouter.tabBar with a TabBar widget, and routes are configured with maintainState: false, unexpected behavior occurs. Switching between tabs with an index difference greater than 1 fails to load the corresponding route.
Example Cases:
Case 1:
Switching from Page 1 to Page 2 by clicking the TabBar widget tab:
Expected Result: Page 2 loads successfully.
Observed Result: Page 2 loads as expected.
Case 2:
Switching from Page 1 to Page 3 by clicking the TabBar widget tab (index difference > 1):
Expected Result: Page 3 should load successfully.
Observed Result: Page 3 does not load. Shows empty page
Case 3:
Switching from Page 1 to Page 4 by clicking the TabBar widget tab (index difference > 1):
Expected Result: Page 4 should load successfully.
Observed Result: Page 4 does not load. Shows empty page
Expected Behavior
When clicking a tab in the TabBar widget, the application should navigate to the corresponding route, regardless of the index difference between the current and target tab. This behavior should not depend on the maintainState: false property or any other configuration.
Observed Behavior
When clicking a tab in the TabBar widget and the route has maintainState: false, switching between tabs with an index difference greater than 1 fails to load the corresponding route.
Workaround
As shown in the code sample the code below make it work as expected when given in TabBar widget:
TabBar(
//...// * SOLUTION: setActiveIndex seperately solves the problem
onTap: (value) => contextTab.tabsRouter.setActiveIndex(value),
// ...
),
1 - maintainState: false in every route, and without TabBar onTap => Observed Scenario
2 - maintainState: false in every route, and with TabBar onTap => Expected Scenario
3 - remove every maintainState: false in every route, and without TabBar onTap => Expected Scenario
4 - remove every maintainState: false in every route, and with TabBar onTap => Expected Scenario
The text was updated successfully, but these errors were encountered:
Scenario
When using
AutoTabsRouter.tabBar
with aTabBar
widget, and routes are configured withmaintainState: false
, unexpected behavior occurs. Switching between tabs with an index difference greater than 1 fails to load the corresponding route.Example Cases:
Case 1:
Switching from Page 1 to Page 2 by clicking the
TabBar
widget tab:Case 2:
Switching from Page 1 to Page 3 by clicking the
TabBar
widget tab (index difference > 1):Case 3:
Switching from Page 1 to Page 4 by clicking the
TabBar
widget tab (index difference > 1):Expected Behavior
When clicking a tab in the
TabBar
widget, the application should navigate to the corresponding route, regardless of the index difference between the current and target tab. This behavior should not depend on themaintainState: false
property or any other configuration.Observed Behavior
When clicking a tab in the
TabBar
widget and the route hasmaintainState: false
, switching between tabs with an index difference greater than 1 fails to load the corresponding route.Workaround
As shown in the code sample the code below make it work as expected when given in TabBar widget:
Code Sample
pubspec.yaml
main.dart
run build_runner to generate main.gr.dart
Test Scenarios
1 - maintainState: false in every route, and without TabBar onTap => Observed Scenario
2 - maintainState: false in every route, and with TabBar onTap => Expected Scenario
3 - remove every maintainState: false in every route, and without TabBar onTap => Expected Scenario
4 - remove every maintainState: false in every route, and with TabBar onTap => Expected Scenario
The text was updated successfully, but these errors were encountered: