java-james / flutter_dotenv

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

Filenotfound when opening dotenv file in module #56

Closed dorsamet closed 2 years ago

dorsamet commented 2 years ago

Hi,

I have a module called "data" inside my main project. That module depends on flutter_dotenv, and has two asset files inside the assets folder as follows:

flutter:

  # To add assets to your package, add an assets section, like this:

  assets:
    - assets/env/.android.env
    - assets/env/.ios.env

I may be defining the files wrong, but I cannot seem to find them when trying to load them in. Am I doing something wrong?

dorsamet commented 2 years ago

The solution comes from a problem in the Flutter ecosystem itself referenced here

It seems like the way to solve for this issue is to include the assets directory inside the lib directory, and that way, there is no need to manually include the assets in the pubspec.yaml. That's not new, but it definitely helps in the implementation. Next, it is important to reference "package/module_name" as the prefix to each file reference, as that's the way the system packages things.

The more you know :)