GetNavigator.onGenerateRoute constructor

GetNavigator.onGenerateRoute({
  1. GlobalKey<NavigatorState>? key,
  2. bool onPopPage(
    1. Route,
    2. dynamic
    )?,
  3. required List<GetPage> pages,
  4. List<NavigatorObserver>? observers,
  5. bool reportsRouteUpdateToEngine = false,
  6. TransitionDelegate? transitionDelegate,
  7. String? initialRoute,
  8. String? restorationScopeId,
})

Implementation

GetNavigator.onGenerateRoute({
  GlobalKey<NavigatorState>? super.key,
  bool Function(Route<dynamic>, dynamic)? onPopPage,
  required List<GetPage> super.pages,
  List<NavigatorObserver>? observers,
  super.reportsRouteUpdateToEngine,
  TransitionDelegate? transitionDelegate,
  super.initialRoute,
  super.restorationScopeId,
}) : super(
        //keys should be optional
        onPopPage: onPopPage ??
            (route, result) {
              final didPop = route.didPop(result);
              if (!didPop) {
                return false;
              }
              return true;
            },
        onGenerateRoute: (settings) {
          final selectedPageList =
              pages.where((element) => element.name == settings.name);
          if (selectedPageList.isNotEmpty) {
            final selectedPage = selectedPageList.first;
            return GetPageRoute(
              page: selectedPage.page,
              settings: settings,
            );
          }
          return null;
        },
        observers: [
          // GetObserver(),
          ...?observers,
        ],
        transitionDelegate:
            transitionDelegate ?? const DefaultTransitionDelegate<dynamic>(),
      );