configurable/lib/system_config.dart
2021-03-24 13:34:03 +07:00

27 lines
711 B
Dart

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}) {
return getProvider().getOrNull(key, defaultValue: defaultValue);
}
}