flutter_dotenv 2.0.1 copy "flutter_dotenv: ^2.0.1" to clipboard
flutter_dotenv: ^2.0.1 copied to clipboard

outdated

Easily configure any flutter application with global variables using a `.env` file.

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
1795
likes
0
pub points
100%
popularity

Publisher

unverified uploader

Easily configure any flutter application with global variables using a `.env` file.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, meta

More

Packages that depend on flutter_dotenv