GoRoute constructor

GoRoute({
  1. required String path,
  2. String? name,
  3. GoRouterWidgetBuilder? builder,
  4. GoRouterPageBuilder? pageBuilder,
  5. GlobalKey<NavigatorState>? parentNavigatorKey,
  6. GoRouterRedirect? redirect,
  7. ExitCallback? onExit,
  8. List<RouteBase> routes = const <RouteBase>[],
})

Constructs a GoRoute.

  • path and name cannot be empty strings.
  • One of either builder or pageBuilder must be provided.

Implementation

GoRoute({
  required this.path,
  this.name,
  this.builder,
  this.pageBuilder,
  super.parentNavigatorKey,
  super.redirect,
  this.onExit,
  super.routes = const <RouteBase>[],
})  : assert(path.isNotEmpty, 'GoRoute path cannot be empty'),
      assert(name == null || name.isNotEmpty, 'GoRoute name cannot be empty'),
      assert(pageBuilder != null || builder != null || redirect != null,
          'builder, pageBuilder, or redirect must be provided'),
      assert(onExit == null || pageBuilder != null || builder != null,
          'if onExit is provided, one of pageBuilder or builder must be provided'),
      super._() {
  // cache the path regexp and parameters
  _pathRE = patternToRegExp(path, pathParameters);
}