args<T> method

T args<T>()

Implementation

T args<T>() {
  if (_shouldUseMock) {
    return GetTestMode.arguments as T;
  }
  // Dialogs and bottom sheets are pushed imperatively on the navigator
  // and never enter the delegate's page stack, so arguments given to
  // `Get.dialog`/`Get.bottomSheet` live only in the overlay route's
  // settings. While such an overlay is topmost, honor its arguments;
  // an overlay opened without arguments keeps exposing the underlying
  // page's arguments, and closing the overlay restores them.
  final overlayRoute = _routingOrNull?.route;
  if (overlayRoute != null &&
      (_isDialogRoute(overlayRoute) || _isBottomSheetRoute(overlayRoute)) &&
      overlayRoute.isCurrent &&
      overlayRoute.settings.arguments != null) {
    return overlayRoute.settings.arguments as T;
  }
  return rootController.rootDelegate.arguments<T>();
}