popInTabToFirst method

void popInTabToFirst(
  1. AppTabType appTab, {
  2. bool clearStack = true,
})

Pops all dialogs bottom sheets and global routes in given tab

Implementation

void popInTabToFirst(AppTabType appTab, {bool clearStack = true}) {
  final navigator = currentTabKeys[appTab];

  if (navigator == null) {
    return;
  }

  // coverage:ignore-start
  navigator.currentState?.popUntil((route) => route.isFirst);
  // coverage:ignore-end

  if (!clearStack) {
    return;
  }

  final firstRoute = navigationStack.tabNavigationStack.stack[currentTab]![0];

  navigationStack.tabNavigationStack.replaceStack(
    routeName: firstRoute.name as RouteType,
    tab: appTab,
    settings: const UIRouteSettings(uniqueInStack: true),
  );
}