Skip to content

Commit

Permalink
added update for the env-plugin section
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanpodila committed Dec 17, 2024
1 parent c32210e commit 21a66d2
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/content/docs/guides/using-plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ container or the scoped container.
Here is an example of the TMDB feature that uses the `init()` to register some
feature-level dependencies:

```dart {8-10}
```dart {8-10} title="feature_tmdb/feature.dart"
final feature = FeatureDescriptor(
name: 'tmdb',
title: 'TMDB',
Expand All @@ -327,7 +327,44 @@ TBD

## Using the `EnvPlugin`

TBD
The env plugin is useful for loading environment settings from a `.env` file. We
use the `flutter_dotenv` package from _pub.dev_ to load these settings. The
env-plugin makes it convenient for us to load it up automatically and make it
available on `vyuh.env`.

The plugin assumes that you have a `.env` file in your application package which
is loaded automatically at runtime. Also, make sure to include it in your assets
section of `pubspec.yaml`.

```yaml {4} title="pubspec.yaml"
flutter:
uses-material-design: true
assets:
- .env
- assets/app-icon.png
```
As an example, notice how the TMDB feature uses the env plugin to load the
`TMDB_ API_KEY` in the `init()` method.

```dart {8} title="feature_tmdb/feature.dart"
final feature = FeatureDescriptor(
name: 'tmdb',
title: 'TMDB',
description:
'Uses the TMDB API to show details of movies with ability to favorite and add to watchlists',
icon: Icons.movie_creation_outlined,
init: () async {
final apiKey = vyuh.env.get('TMDB_API_KEY');
vyuh.di.register(TMDBClient(apiKey));
// Rest of the init
},
// rest of the feature config
);
```

## Using the `EventPlugin`

Expand Down

0 comments on commit 21a66d2

Please sign in to comment.