33 lines
806 B
Dart
33 lines
806 B
Dart
enum Environment {
|
|
production,
|
|
}
|
|
|
|
class AppConfig {
|
|
static const Environment currentEnvironment = Environment.production;
|
|
|
|
static final Map<Environment, List<String>> _environmentHosts = {
|
|
Environment.production: [
|
|
'h5-im.imharry.work',
|
|
],
|
|
};
|
|
|
|
static List<String> get environmentHosts {
|
|
return _environmentHosts[currentEnvironment] ?? const [];
|
|
}
|
|
|
|
static String get homeUrl {
|
|
final host = environmentHosts.isNotEmpty
|
|
? environmentHosts.first
|
|
: 'h5-im.imharry.work';
|
|
return _normalizeHomeUrl(host);
|
|
}
|
|
|
|
static String _normalizeHomeUrl(String host) {
|
|
final value = host.trim();
|
|
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
return value.endsWith('/') ? value : '$value/';
|
|
}
|
|
return 'https://$value/';
|
|
}
|
|
}
|