getDouble static method

double getDouble(
  1. String key, {
  2. double? defaultValue,
})

Retrieves the double value for key.

Parses the string value as a double. Returns defaultValue if key is absent. Throws StateError if key is absent and no defaultValue is provided, or if the value cannot be parsed as a double.

Implementation

static double getDouble(String key, {double? defaultValue}) {
  if (_env.containsKey(key)) {
    final parsed = double.tryParse(_env[key]!);
    if (parsed != null) return parsed;
  }
  if (defaultValue != null) return defaultValue;
  throw StateError(
      'BloomEnv: Missing required double environment variable "$key".');
}