GoRouter constructor

GoRouter({
  1. required List<RouteBase> routes,
  2. OnEnter? onEnter,
  3. Codec<Object?, Object?>? extraCodec,
  4. GoExceptionHandler? onException,
  5. GoRouterPageBuilder? errorPageBuilder,
  6. GoRouterWidgetBuilder? errorBuilder,
  7. GoRouterRedirect? redirect,
  8. int redirectLimit = 5,
  9. Listenable? refreshListenable,
  10. bool routerNeglect = false,
  11. String? initialLocation,
  12. bool overridePlatformDefaultLocation = false,
  13. Object? initialExtra,
  14. List<NavigatorObserver>? observers,
  15. bool debugLogDiagnostics = false,
  16. GlobalKey<NavigatorState>? navigatorKey,
  17. String? restorationScopeId,
  18. bool requestFocus = true,
})

Default constructor to configure a GoRouter with a routes builder and an error page builder.

The routes must not be null and must contain an GoRouter to match /.

Implementation

factory GoRouter({
  required List<RouteBase> routes,
  OnEnter? onEnter,
  Codec<Object?, Object?>? extraCodec,
  GoExceptionHandler? onException,
  GoRouterPageBuilder? errorPageBuilder,
  GoRouterWidgetBuilder? errorBuilder,
  GoRouterRedirect? redirect,
  int redirectLimit = 5,
  Listenable? refreshListenable,
  bool routerNeglect = false,
  String? initialLocation,
  bool overridePlatformDefaultLocation = false,
  Object? initialExtra,
  List<NavigatorObserver>? observers,
  bool debugLogDiagnostics = false,
  GlobalKey<NavigatorState>? navigatorKey,
  String? restorationScopeId,
  bool requestFocus = true,
}) {
  return GoRouter.routingConfig(
    routingConfig: _ConstantRoutingConfig(
      RoutingConfig(
        routes: routes,
        redirect: redirect ?? RoutingConfig._defaultRedirect,
        onEnter: onEnter,
        redirectLimit: redirectLimit,
      ),
    ),
    extraCodec: extraCodec,
    onException: onException,
    errorPageBuilder: errorPageBuilder,
    errorBuilder: errorBuilder,
    refreshListenable: refreshListenable,
    routerNeglect: routerNeglect,
    initialLocation: initialLocation,
    overridePlatformDefaultLocation: overridePlatformDefaultLocation,
    initialExtra: initialExtra,
    observers: observers,
    debugLogDiagnostics: debugLogDiagnostics,
    navigatorKey: navigatorKey,
    restorationScopeId: restorationScopeId,
    requestFocus: requestFocus,
  );
}