Skip to content

Instance of 'NotInitializedError' in Flutter integration #127

Open

Description

@rohxnn

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:profitolio_mobile/config/app_theme.dart';
import 'package:profitolio_mobile/screens/login/login_screen.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await dotenv.load(
fileName: '.env');

runApp(MyApp());
}

class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Login',
theme: AppTheme.lightTheme,
home: LoginScreen(),
);
}
}

I am getting this error. It would be helpful if someone could come up with a solution. :)
╞═══════════════════════════════════════════════════════════
js_primitives.dart:28 The following NotInitializedError was thrown building Builder:
js_primitives.dart:28 Instance of 'NotInitializedError'

Activity

  1. Repository owner deleted a comment from prabhunath111 on May 15, 2025
  2. pankajram1101 commented on Jun 15, 2025

    @pankajram1101

    First you need to load the .env file after that you can fatch the value

  3. java-james commented on Apr 21, 2026

    @java-james
    Owner

    With 6.0.X release coming you will now gets clear "call load()/loadFromString()" message.

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