Go to file
Sambo Chea 8835deafed Fixed test deps and upgrade to 1.0.1 2021-03-24 15:02:06 +07:00
.github/workflows Add github actions to publish to pub.dev 2021-03-24 14:41:14 +07:00
bin Add configuration provider and simple provider functions 2021-03-24 13:24:40 +07:00
example Add example and add more tests and fixed function 2021-03-24 14:17:47 +07:00
lib Add configurable with functions 2021-03-24 14:10:25 +07:00
test Add example and add more tests and fixed function 2021-03-24 14:17:47 +07:00
.env Add dotenv configuration provider 2021-03-24 13:52:20 +07:00
.gitignore Add configuration provider and simple provider functions 2021-03-24 13:24:40 +07:00
analysis_options.yaml Add configuration provider and simple provider functions 2021-03-24 13:24:40 +07:00
CHANGELOG.md Add configuration provider and simple provider functions 2021-03-24 13:24:40 +07:00
LICENSE Create LICENSE 2021-03-24 14:47:16 +07:00
pubspec.lock Fixed test deps and upgrade to 1.0.1 2021-03-24 15:02:06 +07:00
pubspec.yaml Fixed test deps and upgrade to 1.0.1 2021-03-24 15:02:06 +07:00
README.md Add code example for readme 2021-03-24 14:22:56 +07:00

Dart Configurable Environment

  • Allow to get property from env file
  • Cache property for runtime
  • Dotenv file support (use DotenvConfigurationProvider)
  • Support functions (getConfig, getConfigOrNull, hasConfigKey)
  • Support nullsafety (dart 2.12.2+)

Example

import 'package:configurable/dotenv_configuration_provider.dart';
import 'package:configurable/simple_configuration_provider.dart';
import 'package:configurable/system_config.dart';

void main() {
  var key = 'app.name';
  var value = 'CUBETIQ Solution';

  // in-memory provider (built-in)
  var simpleProvider = SimpleConfigurationProvider();
  SystemConfig.setProvider(simpleProvider);
  var result1 = SystemConfig.getOrNull(key, defaultValue: value);
  // output: CUBETIQ Solution
  print(result1);

  // dotenv provider (from file .env)
  var dotenvProvider = DotenvConfigurationProvider();
  SystemConfig.setProvider(dotenvProvider);
  var result2 = SystemConfig.getOrNull('HOME');

  // output: user's home directory
  print(result2);
}

Contributors