dotenv 0.1.1+2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 40

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 #

changelog #

This project follows pub-flavored semantic versioning.

Release notes are available on github.

0.1.1+2 #

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

0.1.1+1 #

  • [fix] whitespace causes quotes not to be stripped

0.1.1 #

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

0.1.0 #

Initial release.

example/example.dart

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

get env => dotenv.env;

final log = new Logger('example');

void main() {
  _config();

  dotenv.load();
  log.info('main: value of foo is ${env['foo']}');
  log.info('main: value of baz is ${env['baz']}');
}

void _config() {
  Logger.root.level = Level.FINE;
  Logger.root.onRecord.listen((LogRecord rec) {
    print('${rec.level.name} ${_toMsg(rec)}');
  });
}

String _toMsg(LogRecord rec) =>
    '${rec.time}: [${rec.loggerName}] ${rec.message}';

Use this package as a library

1. Depend on it

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


dependencies:
  dotenv: ^0.1.1+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub 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...

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

This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0