Skip to content

Latest commit

 

History

History
104 lines (70 loc) · 2.5 KB

File metadata and controls

104 lines (70 loc) · 2.5 KB

How to use --dart-define-from-file with .env and json files

Did you know?

--dart-define-from-file supports both .env and json files.

Here's how to use it.


Then, you can use String.fromEnvironment to read the keys in your Dart code.

For convenience, define an Env class that holds all the keys in one place. This makes it easier to use them.

Extra tip: when your app starts, throw an exception if the keys are not defined (this will help you catch any configuration errors):

For a more in-depth guide about API keys in Flutter, read:


Previous Next
Get the Current Method Name (Hack) Use unawaited for your analytics calls