replaceHost method
Returns a new URI with the host replaced by newHost, or this URI if
newHost is empty.
Example:
Uri.parse('https://example.com/path').replaceHost('newdomain.com');
// Returns: https://newdomain.com/path
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
Uri replaceHost(String newHost) {
if (newHost.isEmpty) {
return this;
}
return replace(host: newHost);
}