dotenv library

Loads environment variables from a .env file.

usage

Once you call load, the top-level env map is available. You may wish to prefix the import.

import 'package:dotenv/dotenv.dart' show load, env;

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

Verify required variables are present:

const _requiredEnvVars = const ['host', 'port'];
bool get hasEnv => isEveryDefined(_requiredEnvVars);

Classes

Parser
Creates key-value pairs from strings formatted as environment variable definitions.

Properties

env Map<String, String>
A copy of Platform.environment including variables loaded at runtime from a file.
no setter

Functions

clean() Map
Overwrite env with a new writable copy of Platform.environment.
isEveryDefined(Iterable<String> vars) bool
True if all supplied variables have nonempty value; false otherwise. Differs from containsKey by excluding null values. Note load should be called first.
load([String filename = '.env', Parser psr = const Parser()]) → void
Read environment variables from filename and add them to env. Logs to stderr if filename does not exist.