Go to file
2021-03-24 14:47:24 +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 Add dotenv configuration provider 2021-03-24 13:52:20 +07:00
pubspec.yaml Updated the package pubpspec for details 2021-03-24 14:32:42 +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