Skip to content

Error: FileNotFoundError on fluter project with module #89

Open

Description

@romulogomesbsi

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):

Activity

  1. Dev-Ayan-Dasgupta commented on Aug 1, 2023

    @Dev-Ayan-Dasgupta

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

  2. neeraj15022001 commented on Aug 9, 2023

    @neeraj15022001
    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

  3. jsmile commented on Aug 18, 2023

    @jsmile

    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
    
    • I made '.env' file in the project root.
    • I have loaded in a flutter app
    void main() async {
      await dotenv.load(fileName: '.env');
      runApp(const MyApp());
    }  
    
    
  4. beibeigd commented on Dec 8, 2023

    @beibeigd

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

    pubspec.yaml

    √

    flutter:
      assets:
        - .env
    

    ×

    flutter:
    assets:
      - .env
    
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