flutter_dotenv icon indicating copy to clipboard operation
flutter_dotenv copied to clipboard

Instance of 'NotInitializedError' in Flutter integration

Open rohxnn opened this issue 1 year ago • 1 comments

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'

rohxnn avatar Mar 12 '25 10:03 rohxnn

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

pankajram1101 avatar Jun 15 '25 15:06 pankajram1101