Skip to content

How to user Flutter_dotenv on Web #75

Open

Description

@reiko-dev

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

Activity

  1. jstdk commented on Nov 4, 2022

    @jstdk

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

  2. robert-virkus commented on Nov 24, 2022

    @robert-virkus

    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
  3. arefrafei92 commented on Jul 6, 2024

    @arefrafei92

    If somebody else reached out here, here is your answer : ##95 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions