java-james / flutter_dotenv

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

Error: FileNotFoundError on fluter project with module #89

Open romulogomesbsi opened 11 months ago

romulogomesbsi commented 11 months ago

I'm working on a flutter project with Module. This package doesn't work correctly here, but if I build a normal project, I don't get this error.

E/flutter (27891): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Instance of 'FileNotFoundError' E/flutter (27891): #0 DotEnv._getEntriesFromFile dotenv.dart:111 E/flutter (27891): <asynchronous suspension> E/flutter (27891): #1 DotEnv.load dotenv.dart:68 E/flutter (27891): <asynchronous suspension> E/flutter (27891): #2 main main.dart:9 E/flutter (27891): <asynchronous suspension> E/flutter (27891):

Dev-Ayan-Dasgupta commented 11 months ago

Did you include .env in pubspec.yaml under assets?

neeraj15022001 commented 10 months ago
Screenshot 2023-08-10 at 1 15 29 AM

Facing same issue when running Flutter on web, though i haven't tried on other platforms.

Pubspec.yaml

Screenshot 2023-08-10 at 1 17 11 AM

I have added env to assets as told in docs

jsmile commented 10 months ago

I have the same trouble:

E/flutter (28853): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Instance of 'FileNotFoundError'

- my pubspec.yaml

name: open_weather_cubit
description: A Flutter BLoC - OpenWeather Cubit project.

publish_to: 'none' 

version: 1.0.0+1

environment:
  sdk: '>=3.1.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  equatable: ^2.0.5
  flutter_bloc: ^8.1.3
  flutter_dotenv: ^5.1.0
  http: ^1.1.0
  recase: ^4.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

assets:
  - assets/images/loading.gif
  - .env
beibeigd commented 6 months ago

I tried to solve it like this in windows. .env file cannot be empty.

pubspec.yaml

flutter:
  assets:
    - .env

×

flutter:
assets:
  - .env