web_app_config 2.0.1

Dart native
Flutter Android iOS

Tools for configuring web apps with environment variables and YAML

web_app_config #

Tools to configure Dart web apps using environment variables.

Example #

The example/ directory contains an example project.

When the server runs, it writes a config.json file based on the desired environment variables:

const List<String> supportedKeys = const <String>[
  'app_name',
  'app_description',
  'app_version',
];

Future main() async {
  await wconfig.writeConfigFromEnvironment(supportedKeys);
  // ...

Then, when the client runs, that configuration can be loaded and parsed into a map:

const List<String> supportedKeys = const <String>[
  'app_name',
  'app_description',
  'app_version',
];

Future main() async {
  await wconfig.writeConfigFromEnvironment(supportedKeys);

When app is run in development mode, (pub serve or webdev serve) the configuration is loaded from web/config.yaml

pub build # Dart 2: webdev build

dart bin/server.dart

# observe the app says "name: my awesome app", configured in config.yaml

# stop server

export APP_NAME="i am configured using an env var"

dart bin/server.dart

# observe the app now says "name: i am configured using an env var" 

# stop server

unset APP_NAME

dart bin/server.dart

# observe the app says "name: my awesome app" again

0
likes
80
pub points
6%
popularity

Publisher

jpryan.me

Tools for configuring web apps with environment variables and YAML

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

dart2_constant, http, yaml

More

Packages that depend on web_app_config