GetNavigator.onGenerateRoute constructor
GetNavigator.onGenerateRoute({
- GlobalKey<
NavigatorState> ? key, - bool onPopPage(
- Route,
- dynamic
- required List<
GetPage> pages, - List<
NavigatorObserver> ? observers, - bool reportsRouteUpdateToEngine = false,
- TransitionDelegate? transitionDelegate,
- String? initialRoute,
- 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>(),
);