Skip to content

Commit

Permalink
fix tab broken issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shakeebkhan66 committed Jun 14, 2024
1 parent 9505ccc commit 530ce7b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/screens/mobile/mobile_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,31 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
_tabData.add(TabData());
_argsProviders.add(ArgsProvider());
_kwargsProviders.add(KwargsProvider());
_updateTabController();
_tabController.index = newIndex;
_updateTabController(newIndex);
});
}

void _removeTab(int index) {
setState(() {
int newIndex = _tabController.index;
_tabNames.removeAt(index);
_tabContents.removeAt(index);
_tabData[index].disposeControllers();
_tabData.removeAt(index);
_argsProviders.removeAt(index);
_kwargsProviders.removeAt(index);
_updateTabController();
if (newIndex >= _tabNames.length) {
newIndex = _tabNames.length - 1;
}

_updateTabController(newIndex);
});
}

void _updateTabController() {
void _updateTabController(int targetIndex) {
if (_tabController.length != _tabNames.length) {
_initializeTabController();
_tabController.index = targetIndex;
}
}

Expand Down

0 comments on commit 530ce7b

Please sign in to comment.