dotenv
dotenv copied to clipboard
This package doesn't seem to work for a dart cli
As soon as you build an executable for your dart cli and run that executable from the terminal. It can't find the .env file and throws the following error
[dotenv] Load failed: file not found: File: 'production.env'
This package only load the host machine environment and/or a external environment file that must be available on the host machine at runtime.
If you are looking for bundling your environment variables in production, you need to define it when compiling your binary.
To specify an environment declaration when running or compiling a Dart application, use the --define option or its abbreviation, -D. Specify the declaration key-value pair using a <NAME>=<VALUE> format:
dart run --define=DEBUG=true -DFLAVOR=free
See: https://dart.dev/guides/environment-declarations.