remove method
Returns a new instance of RouteMatchList with the input match
removed
from the current instance.
Implementation
RouteMatchList remove(RouteMatchBase match) {
final List<RouteMatchBase> newMatches =
_removeRouteMatchFromList(matches, match);
if (newMatches == matches) {
return this;
}
final String fullPath = _generateFullPath(newMatches);
if (this.fullPath == fullPath) {
return copyWith(
matches: newMatches,
);
}
// Need to remove path parameters that are no longer in the fullPath.
final List<String> newParameters = <String>[];
patternToRegExp(fullPath, newParameters);
final Set<String> validParameters = newParameters.toSet();
final Map<String, String> newPathParameters =
Map<String, String>.fromEntries(
pathParameters.entries.where((MapEntry<String, String> value) =>
validParameters.contains(value.key)),
);
final Uri newUri =
uri.replace(path: patternToPath(fullPath, newPathParameters));
return copyWith(
matches: newMatches,
uri: newUri,
pathParameters: newPathParameters,
);
}