replaceHost method

Uri replaceHost(
  1. String newHost
)

Returns a new URI with the host replaced.

Args:

  • newHost: The new host to use.

Returns: A new URI with the replaced host, or this URI if newHost is empty.

Example:

Uri.parse('https://example.com/path').replaceHost('newdomain.com');
// Returns: https://newdomain.com/path

Implementation

Uri replaceHost(String newHost) {
  if (newHost.isEmpty) return this;
  return replace(host: newHost);
}