0 purchases
common configs
Common configs #
A simple package which can be used as a global config in your app or you can share configs with your packages.
Features #
Use as a global configs across your app.
Share configs with packages.
Access config from anywhere.
Load configs from a Map with [Config.fromMap].
Getting started #
Add this package as a dependency
dart pub add common_configs
copied to clipboard
and import in your file by adding the below statement
import 'package:common_configs/common_configs.dart';
copied to clipboard
Usage #
A short example.
Use anything to use as an identifier for your config's type. In this example,
I'm using an enum ConfigType.
enum ConfigType {
devel,
staging,
prod,
}
copied to clipboard
We'll use a pre-existing MapConfig which uses Map<String, dynamic> as a
Config with an identifier.
Config createDevelConfig() => MapConfig(ConfigType.devel, { 'hello': 'world' });
copied to clipboard
To create your own config, start by extending the [Config].
To use this config, set it by using [Config.put].
Config.put(create: createDevelConfig);
copied to clipboard
By default, configs are stored by the name default.
To use a another name, you can use the name parameter when getting or setting a
config.
Config.put(create: createDevelConfig, name: 'app.config');
copied to clipboard
Additional information #
You can write your own code to obtain configuration details from a source like a
json, or .env file.
For a longer example, check out the /example folder.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.