initRouter method

  1. @override
void initRouter({
  1. String? initialLocation,
  2. required List<RouteBase> routes,
  3. required GlobalKey<NavigatorState> rootNavigatorKey,
})
override

Implementation

@override
void initRouter(
    {String? initialLocation,
    required List<g.RouteBase> routes,
    required GlobalKey<NavigatorState> rootNavigatorKey}) {
  final allRoutes = _finalizeRoutes(routes);
  _routingConfig.value = RoutingConfig(routes: allRoutes);

  _router = GoRouter.routingConfig(
    initialLocation: initialLocation ?? '/',
    routingConfig: _routingConfig,
    navigatorKey: rootNavigatorKey,
    debugLogDiagnostics: kDebugMode,
    observers: vyuh.analytics.observers,
    errorBuilder: (context, state) => vyuh.widgetBuilder.routeErrorView(
      context,
      title: 'Failed to load route',
      subtitle: state.matchedLocation,
      error: state.error,
      onRetry: () {
        vyuh.tracker.init(vyuh.tracker.currentState.value);
      },
    ),
  );
}