The asset file '.env' doesn't exist.(Flutter)

45 Views Asked by At

Gave this error in subspece.yaml after add a git

flutter:

  uses-material-design: true

  assets:
    - .env
    - assets/images/
    - assets/icons/

  fonts:
    - family: SFPro DisplayRegular
      fonts:
        - asset: assets/fonts/sf_pro/SFPro_display_regular.ttf
1

There are 1 best solutions below

0
Ivan On

Ensure that the .env file is located at the root of your project folder, at the same level as your pubspec.yaml file, since that is where you've specified it should be found.

If your .env file is not supposed to be in the root folder of your project or is in a different directory, you will need to update the resource path in your pubspec.yaml file accordingly. For example, if the .env file is inside the config folder, you should update the resources section as follows:

flutter:

  uses-material-design: true

  assets:
    - config/.env  # Updated path
    - assets/images/
    - assets/icons/

  fonts:
    - family: SFPro DisplayRegular
      fonts:
        - asset: assets/fonts/sf_pro/SFPro_display_regular.ttf