GoRoute constructor
GoRoute({
- required String path,
- String? name,
- GoRouterWidgetBuilder? builder,
- GoRouterPageBuilder? pageBuilder,
- GoRouterRedirect? redirect,
- ExitCallback? onExit,
- List<
RouteBase> routes = const <RouteBase>[],
Constructs a GoRoute.
path
andname
cannot be empty strings.- One of either
builder
orpageBuilder
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);
}