java-james / flutter_dotenv

Loads environment variables from `.env`.
https://pub.dartlang.org/packages/flutter_dotenv
MIT License
209 stars 46 forks source link

flutter_dotenv looking for env files in imaginary directory #92

Closed Bus42 closed 7 months ago

Bus42 commented 8 months ago

I placed my env files in lib/env This is where I load them in my main.dart


  await dotenv.load(
      fileName: kIsWeb ? 'lib/env/web.env' : 'lib/env/android.env');

Here's the assets section of my pubspec.yaml

  assets:
    - lib/env/
    - lib/assets/images/
    - lib/assets/icons/

This is the error I get Error while trying to load an asset: Flutter Web engine failed to fetch "assets/lib/env/web.env". HTTP request succeeded, but the server responded with HTTP status 404.

I've tried clearing my cache, and searching my entire codebase for where it's getting that from, and nothing. What gives?

EnaEd commented 7 months ago

the same issue when I deployed flutter app to IIS. my pubspec.yaml

assets:

and I've placed cofig file inside root

image

Also not working with .env as file name Any thoughts?

Bus42 commented 7 months ago

It seems to be a "random" error with the Flutter engine. Out of nowhere, one of my apps started looking for a file in a directory that does not exist and is not in my pubspec.yaml.

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/error_messages.json". HTTP request succeeded, but the server responded with HTTP status 404.
assets:
  - lib/src/utils/error_messages.json
Bus42 commented 7 months ago

I've tried clearing my cache and everything else I can imagine, it just won't look for the file where I tell it to.

Bus42 commented 7 months ago

Basically, this doesn't seem to be a dotenv error.