dotenv

Load environment variables at runtime from a .env file.

Pub Version Build Status

NB: Travis uses test_runner, which has not yet moved off unittest.

usage

Prefix the library import and call load(), exposing the env map with a top-level getter.

import 'package:dotenv/dotenv.dart' as dotenv;

Map<String, String> get _env => dotenv.env;

void main() {
  dotenv.load();
  var x = _env['foo'];
  // ...
}

Verify required variables are present:

const _requiredEnvVars = const ['host', 'port'];

bool get hasEnv => dotenv.isEveryDefined(_requiredEnvVars);

limitations

Variable substitution and character escaping is a work in progress. Some cases don't work yet. Pull requests gleefully considered.

prior art

Libraries

dotenv