GoRouter constructor

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