flutter_dotenv 2.0.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 82

flutter_dotenv

Load configuration at runtime from a .env file which can be used throughout the applicaiton.

about

This library is a fork of mockturtl/dotenv dart library with slight changes to make this work with flutter. It parses the .env file into a map contained within a singleton which allows the variables to be used throughout your application.

usage

Create a .env file in the root of your project with the example content:

VAR_NAME=HELLOWORLD

Add the .env file to your assets bundle in pubspec.yaml

  assets:
  - .env

Init the DotEnv singleton in main.dart

Future main() async {
  await DotEnv().load('.env');
  //...runapp
}

Access variables from .env throughout the applicaiton

DotEnv().env['VAR_NAME'];

Optionally you could map DotEnv().env after load to a config model to access config with types.

discussion

Use the issue tracker for bug reports and feature requests.

Pull requests are welcome.

prior art
license: MIT

changelog

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

Release notes are available on github.

2.0.1

  • [docs] tweak app description
  • [fix] increase meta version range

2.0.0

  • Flutter compatible

1.0.0

  • Dart 2 compatible. [#16][]

0.1.3+3

  • [docs] tweak README

0.1.3+2

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

0.1.3+1

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

0.1.3

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

0.1.2

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

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.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_dotenv: ^2.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support 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:flutter_dotenv/flutter_dotenv.dart';
  
Version Uploaded Documentation Archive
2.0.1 Dec 12, 2018 Go to the documentation of flutter_dotenv 2.0.1 Download flutter_dotenv 2.0.1 archive
2.0.0 Dec 12, 2018 Go to the documentation of flutter_dotenv 2.0.0 Download flutter_dotenv 2.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use flutter_dotenv.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.6 1.1.7
Transitive dependencies
collection 1.14.11
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test