description

# replace abstract method

Uri replace({

1. String? scheme,
2. String? userInfo,
3. String? host,
4. int? port,
5. String? path,
6. Iterable<String>? pathSegments,
7. String? query,
8. Map<String, dynamic>? queryParameters,
9. String? fragment,

})

Creates a new `Uri` based on this one, but with some parts replaced.

This method takes the same parameters as the Uri constructor, and they have the same meaning.

At most one of `path` and `pathSegments` must be provided. Likewise, at most one of `query` and `queryParameters` must be provided.

Each part that is not provided will default to the corresponding value from this `Uri` instead.

This method is different from Uri.resolve, which overrides in a hierarchical manner, and can instead replace each part of a `Uri` individually.

Example:

    final uri1 = Uri.parse(
        'https://dart.dev/libraries/dart-core#utility-classes');

    final uri2 = uri1.replace(
        scheme: 'https',
        path: 'libraries/dart-core',
        fragment: 'uris');
    print(uri2); // https://dart.dev/libraries/dart-core#uris

This method acts similarly to using the `Uri` constructor with some of the arguments taken from this `Uri`. Example:

    final Uri uri3 = Uri(
        scheme: 'https',
        userInfo: uri1.userInfo,
        host: uri1.host,
        port: uri2.port,
        path: 'language/built-in-types',
        query: uri1.query,
        fragment: null);
    print(uri3); // https://dart.dev/language/built-in-types

Using this method can be seen as shorthand for the `Uri` constructor call above, but may also be slightly faster because the parts taken from this `Uri` need not be checked for validity again.

## Implementation

    Uri replace({
      String? scheme,
      String? userInfo,
      String? host,
      int? port,
      String? path,
      Iterable<String>? pathSegments,
      String? query,
      Map<String, dynamic /*String?|Iterable<String>*/>? queryParameters,
      String? fragment,
    });