getList method
Retrieves a list of strings from an environment variable.
Splits the value using the specified separator and trims whitespace
from each element.
// With ALLOWED_HOSTS="localhost,127.0.0.1,::1"
final hosts = env.getList('ALLOWED_HOSTS');
// Returns: ['localhost', '127.0.0.1', '::1']
// With semicolon separator
final paths = env.getList('PATHS', separator: ';');
Implementation
@override
List<String> getList(
String key, {
String separator = ',',
List<String> defaultValue = const [],
}) {
final value = _env[key];
if (value == null || value.isEmpty) return defaultValue;
return value.split(separator).map((e) => e.trim()).toList();
}