configurable/lib/system_config.dart
Sambo Chea 33b6355bcf Add configurable with functions
Add more tests for call functions and fixed
2021-03-24 14:10:25 +07:00

29 lines
785 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);
}
static bool containsKey(String key) => getProvider().containsKey(key);
}