Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ flutter_dotenv

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

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

[mockturtl/dotenv]: https://pub.dartlang.org/packages/dotenv

### usage
### Usage

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

Expand All @@ -20,35 +20,43 @@ VAR_NAME=HELLOWORLD

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

```
```yml
assets:
- .env
```
- .env
```

Init the DotEnv singleton in `main.dart`
Add the `.env` file as an entry in your `.gitignore` if it isn't already

```sh
.env*
```

Init the DotEnv singleton in `main.dart`

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

Access variables from `.env` throughout the applicaiton
```

```dart
DotEnv().env['VAR_NAME'];
```

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

#### discussion
#### Discussion

Use the [issue tracker][tracker] for bug reports and feature requests.

Pull requests are welcome.

[tracker]: https://github.com/java-james/flutter_dotenv/issues

###### prior art
###### Prior art

[flutter_dotenv]: https://pub.dartlang.org/packages/dotenv
- [mockturtl/dotenv][] (dart)
Expand All @@ -74,4 +82,4 @@ Pull requests are welcome.
[mefellows/sbt-dotenv]: https://github.com/mefellows/sbt-dotenv
[greenspun/dotenv]: https://www.youtube.com/watch?v=pUjJU8Bbn3g

###### license: [MIT](LICENSE)
###### license: [MIT](LICENSE)