2021-03-24 13:24:40 +07:00
|
|
|
import 'package:configurable/configuration_provider.dart';
|
|
|
|
import 'package:configurable/simple_configuration_provider.dart';
|
|
|
|
|
|
|
|
class SystemConfig {
|
|
|
|
static ConfigurationProvider? provider;
|
|
|
|
|
|
|
|
static void setProvider(ConfigurationProvider provider) {
|
|
|
|
SystemConfig.provider = provider;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ConfigurationProvider getProvider() {
|
|
|
|
if (provider == null) {
|
|
|
|
setProvider(SimpleConfigurationProvider());
|
|
|
|
}
|
|
|
|
|
|
|
|
return provider!;
|
|
|
|
}
|
|
|
|
|
|
|
|
static String get(String key, {String? defaultValue}) {
|
|
|
|
return getOrNull(key, defaultValue: defaultValue)!;
|
|
|
|
}
|
|
|
|
|
|
|
|
static String? getOrNull(String key, {String? defaultValue}) {
|
2021-03-24 13:34:03 +07:00
|
|
|
return getProvider().getOrNull(key, defaultValue: defaultValue);
|
2021-03-24 13:24:40 +07:00
|
|
|
}
|
|
|
|
}
|