GetRouterOutlet.pickPages constructor

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

Implementation

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

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