GetRouterOutlet.pickPages constructor

GetRouterOutlet.pickPages({
  1. required Iterable<GetPage> pickPages(
    1. RouteDecoder currentNavStack
    ),
  2. Key? key,
  3. Widget emptyWidget(
    1. GetDelegate delegate
    )?,
  4. GetPage emptyPage(
    1. GetDelegate delegate
    )?,
  5. bool onPopPage(
    1. Route,
    2. dynamic
    )?,
  6. String? restorationScopeId,
  7. GlobalKey<NavigatorState>? navigatorKey,
  8. GetDelegate? delegate,
})

Implementation

GetRouterOutlet.pickPages({
  required super.pickPages,
  super.key,
  Widget Function(GetDelegate delegate)? emptyWidget,
  GetPage Function(GetDelegate delegate)? emptyPage,
  bool Function(
    Route<dynamic>,
    dynamic,
  )? onPopPage,
  String? restorationScopeId,
  GlobalKey<NavigatorState>? navigatorKey,
  GetDelegate? delegate,
}) : super(
        pageBuilder: (
          BuildContext context,
          GetDelegate rDelegate,
          Iterable<GetPage>? pages,
        ) {
          final Iterable<GetPage> pageRes = <GetPage?>[
            ...?pages,
            if (pages == null || pages.isEmpty) emptyPage?.call(rDelegate),
          ].whereType<GetPage>();

          if (pageRes.isNotEmpty) {
            return InheritedNavigator(
              navigatorKey: navigatorKey ??
                  Get.rootController.rootDelegate.navigatorKey,
              child: GetNavigator(
                restorationScopeId: restorationScopeId,
                onPopPage: onPopPage ??
                    (Route route, result) {
                      final bool didPop = route.didPop(result);
                      if (!didPop) {
                        return false;
                      }
                      return true;
                    },
                pages: pageRes.toList(),
                key: navigatorKey,
              ),
            );
          }
          return emptyWidget?.call(rDelegate) ?? const SizedBox.shrink();
        },
        delegate: delegate ?? Get.rootController.rootDelegate,
      );