I installed flutter_dotenv with this command:
flutter pub add flutter_dotenv
My is pubspec.yaml is like:
dependencies:
flutter:
flutter_dotenv: ^5.0.0
flutter:
assets:
- .env
Then I put .env file in the project root (I will use .env.dev. .env.prd later so you see them in the screen shot):
I run project from VSCode then get FileNotFoundError:
I checked the .env file location hundred of times, tried to change the file name, change the location to /lib etc - still no luck. Any idea?
I found what was wrong. "assets:" must be under "flutter:", so tab is necessary before "assets:". That's it!
flutter:
assets:
- .env
flutter:
assets:
- .env
It's working for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With