pop method

void pop({
  1. dynamic payload,
  2. bool onlyInternalStack = false,
})

Pops latest route from current navigation stack

if onlyInternalStack is true than only removes route data from navigation stack Navigator state stays the same in this case

Implementation

void pop({
  dynamic payload,
  bool onlyInternalStack = false,
}) {
  final isInGlobal = isInGlobalStack();

  final isInBottomSheetApp = isInBottomSheetDialogScope;

  if (!isInBottomSheetApp) {
    if (!isInGlobal) {
      final tabStack = navigationStack.tabNavigationStack.stack[currentTab]!;

      if (tabStack.length == 1) {
        // preventing close of first page in tab stack
        return;
      }
    } else {
      final globalStack = navigationStack.globalNavigationStack.stack;

      if (globalStack.length == 1) {
        // preventing close of first page in tab stack
        return;
      }
    }
  }

  if (onlyInternalStack) {
    navigationStack.pop(currentTab, isInGlobal);

    return;
  }

  final navigator =
      isInBottomSheetApp ? bottomSheetDialogNavigatorKey : getNavigator();

  navigationStack.pop(currentTab, isInGlobal || isInBottomSheetApp);

  navigator.currentState?.pop(payload);
}