dotenv top-level property

DotEnv dotenv
getter/setter pair

Loads environment variables from a .env file.

usage

Once you call (dotenv.load), the env variables can be accessed as a map using the env getter of dotenv (dotenv.env). You may wish to prefix the import.

import 'package:flutter_dotenv/flutter_dotenv.dart';

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

Verify required variables are present:

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

Implementation

DotEnv dotenv = DotEnv();