uri method
The value parsed as a URI — a peer service's base address, typically.
Throws when present but unparseable, and when orElse is omitted and the
variable is unset.
Implementation
Uri uri(String name, {Uri? orElse}) {
final value = this[name];
if (value == null) {
if (orElse case final fallback?) {
return fallback;
}
throw StateError(
'Required environment variable "$name" is not set. '
'Set it to the base URL of the service.',
);
}
return Uri.tryParse(value) ??
(throw StateError(
'Environment variable "$name" is "$value", which is not a URI.',
));
}