jumpToTab method

void jumpToTab(
  1. int index,
  2. BuildContext? context
)

Jump to a specific tab index

Implementation

void jumpToTab(int index, BuildContext? context) {
  if (_controller != null) {
    _controller!.jumpToTab(index);
  } else if (context != null) {
    final state = context.findAncestorStateOfType<TBottomNavigationState>();
    if (state != null) {
      state.controller.jumpToTab(index);
    } else {
      throw Exception(
          'TBottomNavigation not found in widget tree and controller not set');
    }
  } else {
    throw Exception('TBottomNavigation controller not initialized');
  }
}