12

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):

enter image description here

I run project from VSCode then get FileNotFoundError: enter image description here

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?

ASH
  • 459
  • 5
  • 18

2 Answers2

20

I found what was wrong. "assets:" must be under "flutter:", so tab is necessary before "assets:". That's it!

flutter:
  assets:
    - .env
ASH
  • 459
  • 5
  • 18
0
flutter:
  assets:
    - .env

It's working for me.