nslogx / flutter_easyloading

✨A clean and lightweight loading/toast widget for Flutter, easy to use without context, support iOS、Android and Web
https://pub.dev/packages/flutter_easyloading
MIT License
1.25k stars 219 forks source link

ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter_easyloading/src/easy_loading.dart': Failed assertion: line 425 pos 7: 'overlayEntry != null': You should call EasyLoading.init() in your MaterialApp #227

Open thisadee2897 opened 7 months ago

thisadee2897 commented 7 months ago

Describe the bug A clear and concise description of what the bug is.

Flutter/Dart info please run flutter doctor then put it here.

Screenshots If applicable, add screenshots to help explain your problem.

github-actions[bot] commented 7 months ago

Thanks for taking the time to open an issue. I will have a look and answer as soon as possible.

thisadee2897 commented 7 months ago

void main() async { EasyLoading.init(); WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.transparent, systemNavigationBarColor: Colors.transparent, systemNavigationBarDividerColor: Colors.transparent, statusBarIconBrightness: Brightness.dark, systemNavigationBarIconBrightness: Brightness.dark, ), ); await initializeDateFormatting('th', null); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SharedPreferences prefs = await SharedPreferences.getInstance(); bool isLoggedIn = prefs.getBool('isLoggedIn') ?? false; runApp(MyApp(isLoggedIn: isLoggedIn)); App.configLoading(); }

class MyApp extends StatelessWidget { final bool isLoggedIn; const MyApp({super.key, this.isLoggedIn = false}); @override Widget build(BuildContext context) { return GetMaterialApp( builder: (context, child) { // EasyLoading.init(); return MediaQuery( data: MediaQuery.of(context).copyWith( textScaler: TextScaler.noScaling, ), child: child!, ); }, showSemanticsDebugger: false, localizationsDelegates: App.localizations(), supportedLocales: App.local(), theme: App.themeLight(), darkTheme: App.themeLight(), themeMode: ThemeMode.light, debugShowCheckedModeBanner: false, initialBinding: InitialBinding(), initialRoute: isLoggedIn ? BottomNavBar.id : LoginPage.id, getPages: AppPages.pages, ); } }

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter_easyloading/src/easy_loading.dart': Failed assertion: line 425 pos 7: 'overlayEntry != null': You should call EasyLoading.init() in your MaterialApp

mdabusaif commented 6 months ago

https://github.com/nslogx/flutter_easyloading/issues/215#issuecomment-1662461919

@thisadee2897 Check here. This will solve your issue I believe.