flutter_dotenv 2.1.0

  • Readme
  • Changelog
  • Installing
  • 96

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:


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

    - .env

Add the .env file as an entry in your .gitignore if it isn't already


Init the DotEnv singleton in main.dart

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

Access variables from .env throughout the applicaiton


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.1.0 #

  • [new] Support '=' sign in value

2.0.3 #

  • [fix] Warning when using with flutter_test

2.0.2 #

  • [fix] Flutter 1.9.5 compatibility ensure binding was initialized

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:

  flutter_dotenv: ^2.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub 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';
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 Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and flutter_dotenv.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


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