@@ -300,7 +300,7 @@ container or the scoped container.
300
300
Here is an example of the TMDB feature that uses the ` init() ` to register some
301
301
feature-level dependencies:
302
302
303
- ``` dart {8-10}
303
+ ``` dart {8-10} title="feature_tmdb/feature.dart"
304
304
final feature = FeatureDescriptor(
305
305
name: 'tmdb',
306
306
title: 'TMDB',
327
327
328
328
## Using the ` EnvPlugin `
329
329
330
- TBD
330
+ The env plugin is useful for loading environment settings from a ` .env ` file. We
331
+ use the ` flutter_dotenv ` package from _ pub.dev_ to load these settings. The
332
+ env-plugin makes it convenient for us to load it up automatically and make it
333
+ available on ` vyuh.env ` .
334
+
335
+ The plugin assumes that you have a ` .env ` file in your application package which
336
+ is loaded automatically at runtime. Also, make sure to include it in your assets
337
+ section of ` pubspec.yaml ` .
338
+
339
+ ``` yaml {4} title="pubspec.yaml"
340
+ flutter :
341
+ uses-material-design : true
342
+ assets :
343
+ - .env
344
+ - assets/app-icon.png
345
+ ` ` `
346
+
347
+ As an example, notice how the TMDB feature uses the env plugin to load the
348
+ ` TMDB_ API_KEY` in the `init()` method.
349
+
350
+ ` ` ` dart {8} title="feature_tmdb/feature.dart"
351
+ final feature = FeatureDescriptor(
352
+ name: 'tmdb',
353
+ title: 'TMDB',
354
+ description:
355
+ 'Uses the TMDB API to show details of movies with ability to favorite and add to watchlists',
356
+ icon: Icons.movie_creation_outlined,
357
+ init: () async {
358
+ final apiKey = vyuh.env.get('TMDB_API_KEY');
359
+
360
+ vyuh.di.register(TMDBClient(apiKey));
361
+
362
+ // Rest of the init
363
+ },
364
+
365
+ // rest of the feature config
366
+ );
367
+ ` ` `
331
368
332
369
# # Using the `EventPlugin`
333
370
0 commit comments