dotenv 1.0.0

  • Example
  • Installing
  • Versions
  • 84


Load environment variables at runtime from a .env file.

Pub Version Build Status Documentation


Deploying applications should be simple. This implies constraints:

The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code... they are a language- and OS-agnostic standard.

An environment is the set of variables known to a process (say, PATH, PORT, ...). It is desirable to mimic the production environment during development (testing, staging, ...) by reading these values from a file.

This library parses that file and merges its values with the built-in Platform.environment map.


See documentation and examples.


Get the latest:

$ pub global activate dotenv


$ pub global run dotenv:new  # create a .env file and add it to .gitignore
$ pub global run dotenv      # load the file and print the environment to stdout


Use the issue tracker for bug reports and feature requests.

Pull requests gleefully considered.

prior art
license: MIT


This project follows pub-flavored semantic versioning. (more)

Release notes are available on github.


  • Dart 2 compatible. #16


  • [docs] tweak README


  • [fix] don't throw if load fails #11


  • [fix] allow braces with ${var} substitution #10


  • [new] add command-line interface #7, #8
  • [deps] add args@v0.13


  • [new] support variable substitution from Platform.environment #6
  • [deps] drop logging


  • [fix] don't strip # inside quotes #5


  • [fix] whitespace causes quotes not to be stripped


  • [deprecated] Parser internals will become private. #3
    • #unquote, #strip, #swallow, #parseOne, #surroundingQuote, #interpolate
  • [new] support variable substitution
  • [deps] migrate to test
  • [deps] bump logging


Initial release.


import 'dart:io';

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

void main() {

  p('read all vars? ${isEveryDefined(['foo', 'baz'])}');

  p('value of foo is ${env['foo']}');
  p('value of baz is ${env['baz']}');
  p('your home directory is: ${env['HOME']}');


  p('env has key foo? ${env.containsKey('foo')}');
  p('env has key baz? ${env.containsKey('baz')}');
  p('your home directory is still: ${env['HOME']}');

p(String msg) => stdout.writeln(msg);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dotenv: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dotenv/dotenv.dart';
Version Uploaded Documentation Archive
1.0.0 Jul 12, 2018 Go to the documentation of dotenv 1.0.0 Download dotenv 1.0.0 archive
0.1.3+3 Jul 19, 2015 Go to the documentation of dotenv 0.1.3+3 Download dotenv 0.1.3+3 archive
0.1.3+2 Jun 5, 2015 Go to the documentation of dotenv 0.1.3+2 Download dotenv 0.1.3+2 archive
0.1.3+1 May 15, 2015 Go to the documentation of dotenv 0.1.3+1 Download dotenv 0.1.3+1 archive
0.1.3 May 15, 2015 Go to the documentation of dotenv 0.1.3 Download dotenv 0.1.3 archive
0.1.2 May 12, 2015 Go to the documentation of dotenv 0.1.2 Download dotenv 0.1.2 archive
0.1.1+2 May 10, 2015 Go to the documentation of dotenv 0.1.1+2 Download dotenv 0.1.1+2 archive
0.1.1+1 May 10, 2015 Go to the documentation of dotenv 0.1.1+1 Download dotenv 0.1.1+1 archive
0.1.1 May 10, 2015 Go to the documentation of dotenv 0.1.1 Download dotenv 0.1.1 archive
0.1.0 Apr 7, 2015 Go to the documentation of dotenv 0.1.0 Download dotenv 0.1.0 archive

All 11 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6


Detected platforms: Flutter, other

Primary library: package:dotenv/dotenv.dart with components: io.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
args ^1.0.0 1.5.1
dart2_constant ^1.0.0 1.0.2+dart2
meta ^1.0.2 1.1.6
Dev dependencies
collection any
test any