Flutter easyloading package throws the below error
Unhandled Exception: ‘package:flutter_easyloading/src/easy_loading.dart’: Failed assertion
That simply means you are not initializing the init() method of the package. We should do it inside MaterialApp().
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(360, 780),
builder: (context, child) => GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: AppTheme.light,
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
builder: EasyLoading.init(),
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
));
}
}
Here you see the builder:EasyLoading.init() method. Here we have used GetMaterialApp() instead of MaterialApp() since we are using GetX package.