loadFromEnv method
Read well-known environment variables and store them in the global scope.
Implementation
void loadFromEnv({Map<String, String>? overrideEnv}) {
final env = overrideEnv ?? Platform.environment;
for (final entry in _envMapping.entries) {
final envValue = env[entry.key];
if (envValue != null && envValue.isNotEmpty) {
final configKey = entry.value;
dynamic parsed = envValue;
// Attempt numeric / bool coercion.
if (int.tryParse(envValue) != null) {
parsed = int.parse(envValue);
} else if (double.tryParse(envValue) != null) {
parsed = double.parse(envValue);
} else if (envValue.toLowerCase() == 'true') {
parsed = true;
} else if (envValue.toLowerCase() == 'false') {
parsed = false;
}
_store[ConfigScope.global]![configKey] = parsed;
_sources[ConfigScope.global]![configKey] = ConfigSource.env;
}
}
}