dotenv 0.1.1+1 dotenv: ^0.1.1+1 copied to clipboard
Load environment variables from a `.env` file.
dotenv #
Load environment variables at runtime from a .env
file.
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
- bkeepers/dotenv (ruby)
- motdotla/dotenv (node)
- theskumar/python-dotenv (python)
- joho/godotenv (golang)
- slapresta/rust-dotenv (rust)
- chandu/dotenv (c#)
- tpope/lein-dotenv, rentpath/clj-dotenv (clojure)
- mefellows/sbt-dotenv (scala)
- greenspun/dotenv (half of common lisp)