getRouterConfig method
- AppAttributes appAttributes,
- AnimationController controller,
- void handleChangedPageIndex(
- int value
- int currentPageIndex,
inherited
Implementation
GoRouter getRouterConfig(
AppAttributes appAttributes,
AnimationController controller,
final void Function(int value) handleChangedPageIndex,
int currentPageIndex,
) {
return GoRouter(
navigatorKey: _rootNavigatorKey,
initialLocation: _getInitialLocation(appAttributes, currentPageIndex),
routes: <RouteBase>[
StatefulShellRoute.indexedStack(
builder:
(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) {
// Return the widget that implements the custom shell (in this case
// using a BottomNavigationBar). The StatefulNavigationShell is passed
// to be able access the state of the shell and to navigate to other
// branches in a stateful way.
return Home(
handleChangedPageIndex: handleChangedPageIndex,
scaffoldKey: scaffoldKey,
footer: getFooter(appAttributes),
appAttributes: appAttributes,
controller: controller,
navigationShell: navigationShell,
);
},
branches: createBranches(appAttributes),
),
],
redirect: (BuildContext context, GoRouterState state) {
var allValidRoutes = appAttributes.screenConfigurations
.getAllValidRoutes();
if (!allValidRoutes.contains(state.fullPath)) {
return appAttributes.screenConfigurations
.getErrorPagesConfig()
.first
.getRoutingName();
}
// no need to redirect at all
return null;
},
);
}