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