boolean method
The value parsed as a boolean.
true, 1, yes and on are true; false, 0, no and off are
false, each case-insensitively. Anything else throws rather than being
quietly read as false — a feature flag set to "maybe" should be a
deployment error, not a silent no.
Implementation
bool boolean(String name, {required bool orElse}) {
final value = this[name]?.toLowerCase();
if (value == null) {
return orElse;
}
return switch (value) {
'true' || '1' || 'yes' || 'on' => true,
'false' || '0' || 'no' || 'off' => false,
_ => throw StateError(
'Environment variable "$name" is "$value", which is not a boolean.',
),
};
}