requireUri method
Reads a required absolute URI environment variable.
Validates that the parsed Uri has a scheme (e.g. http, https, wss).
Throws BloomEnvironmentException if the variable is missing, blank, unparseable,
or lacks a valid URI scheme.
late final Uri databaseUri = requireUri('DATABASE_URL');
Implementation
Uri requireUri(String key, {String? description}) {
final str = requireString(key, description: description);
final parsed = Uri.tryParse(str);
if (parsed == null || !parsed.hasScheme) {
final err =
'Environment variable "$key" is not a valid absolute URI: "$str".';
_validationErrors.add(err);
throw BloomEnvironmentException(err, errors: [err]);
}
return parsed;
}