override method

RouteMatch override(
  1. RouteMatch route,
  2. RouteMatcher matcher
)

Builds a new PageRouteInfo with the provided overrides

Implementation

RouteMatch override(RouteMatch route, RouteMatcher matcher) {
  final matches = <RouteMatch>[];
  if (children != null) {
    final coll = matcher.collection.subCollectionOf(route.name);
    final subMatcher = RouteMatcher(coll);
    for (final child in children!) {
      final match = subMatcher.matchByRoute(child);
      if (match == null) {
        throw FlutterError(
          "Failed to navigate to overridden child ${child.routeName}.\nPlease make sure the route is declared as a child of ${route.name}",
        );
      }
      matches.add(match);
    }
  }
  return route.copyWith(
    args: args,
    queryParams: queryParams == null ? null : Parameters(queryParams),
    children: matches.isEmpty ? null : matches,
    fragment: fragment,
  );
}