AppConfig.load constructor
AppConfig.load()
Loads ALLOWED_ORIGINS from .env as a comma-separated list.
Implementation
factory AppConfig.load() {
final env = DotEnv(includePlatformEnvironment: true, quiet: true);
try {
env.load();
} catch (e) {
print('Warning: could not load .env file: $e');
}
final raw = env['ALLOWED_ORIGINS'] ?? '';
final origins = raw
.split(',')
.map((s) => s.trim())
.where((s) => s.isNotEmpty)
.toList();
// Ensure type safety: List<String>
final List<String> parsedOrigins = origins.cast<String>();
return AppConfig._(parsedOrigins);
}