GetRouterOutlet constructor

GetRouterOutlet({
  1. required String initialRoute,
  2. Key? key,
  3. String? anchorRoute,
  4. Iterable<GetPage> filterPages(
    1. Iterable<GetPage> afterAnchor
    )?,
  5. GetDelegate? delegate,
  6. String? restorationScopeId,
})

Creates a GetRouterOutlet that picks pages from the current route configuration.

Implementation

GetRouterOutlet({
  required String initialRoute,
  Key? key,
  String? anchorRoute,
  Iterable<GetPage> Function(Iterable<GetPage> afterAnchor)? filterPages,
  GetDelegate? delegate,
  String? restorationScopeId,
}) : this.pickPages(
        restorationScopeId: restorationScopeId,
        pickPages: (RouteDecoder config) {
          // Handle based on whether an anchor route is provided
          if (anchorRoute == null) {
            // No anchor route - jump the ancestor path
            final length = Uri.parse(initialRoute).pathSegments.length;
            return config.currentTreeBranch
                .skip(length)
                .take(length)
                .toList();
          } else {
            // With anchor route - pick routes after the anchor
            var result = config.currentTreeBranch.pickAfterRoute(anchorRoute);
            // Apply filter if provided
            if (filterPages != null) {
              result = filterPages(result);
            }
            return result;
          }
        },
        key: key,
        emptyPage: (GetDelegate delegate) =>
            delegate.matchRoute(initialRoute).route ?? delegate.notFoundRoute,
        navigatorKey: Get.nestedKey(anchorRoute)?.navigatorKey,
        delegate: delegate,
      );