flutter_dotenv icon indicating copy to clipboard operation
flutter_dotenv copied to clipboard

How to user Flutter_dotenv on Web

Open reiko-dev opened this issue 3 years ago • 3 comments
trafficstars

Do I need some additional step for using this package on web?

I'm running it on Android/IOS and all goes fine.

But when I try to run the project on Web I get the follwing errors:

3  Locations: No module for http://localhost:58501/dart_sdk.js 

Locations: No module for http://localhost:58501/dart_sdk.js 

Locations: No module for http://localhost:58501/dart_sdk.js 

Locations: No module for http://localhost:58501/dart_sdk.js 

109  Locations: No module for http://localhost:58501/dart_sdk.js 

Locations: No module for http://localhost:58501/

image

The code for loading the dotenv files is: await dotenv.load( fileName: 'assets/${kReleaseMode ? 'prod.env' : 'dev.env'}', );

My env files are under the assets folder
image

The files are also added to pubspec.yaml as:

image

reiko-dev avatar Oct 30 '22 20:10 reiko-dev

Same question here. Can't get it to work on Vercel & Netlify

jstdk avatar Nov 04 '22 14:11 jstdk

In may case I had to move the .env file into the root of my project, then it worked fine. So in pubspec.yaml I have:

  assets:
    - .env

robert-virkus avatar Nov 24 '22 12:11 robert-virkus

If somebody else reached out here, here is your answer : #https://github.com/java-james/flutter_dotenv/issues/95#issuecomment-2185508812

z85510 avatar Jul 06 '24 21:07 z85510