isInGlobalStack method

bool isInGlobalStack({
  1. bool includeBottomSheetsAndDialogs = true,
})

Checks if navigator now in global stack or in tab stack

Implementation

bool isInGlobalStack({bool includeBottomSheetsAndDialogs = true}) {
  if (!settings.appContainsTabNavigation) {
    return true;
  }

  final isHomePresentInStack =
      navigationStack.globalNavigationStack.stack.indexWhere(
            (element) => element.name == settings.tabViewHomeRoute,
          ) !=
          -1;

  final bool isGlobalStack = includeBottomSheetsAndDialogs
      ? navigationStack.globalNavigationStack.stack.length > 1
      : navigationStack.globalNavigationStack.stack
              .where((element) =>
                  element.name is! BottomSheetType &&
                  element.name is! DialogType)
              .length >
          1;

  return !isHomePresentInStack || isGlobalStack;
}