Am completely new to flutter and as matter of fact this is my first bite in using it and I really can’t figure out why dart is yelling at me when using ScreenUtilInit
from flutter_screenutil package, with invalid constant value
error coming from builder: (context, child)
. I have searched everywhere on the web and read the pub documentation and i still couldn’t find tune how to appease these choking bug.
Here is the code snippets
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const ScreenUtilInit(
useInheritedMediaQuery: true,
designSize: Size(375, 812),
minTextAdapt: true,
splitScreenMode: true,
// The Invalid constant value is coming from the next line
builder: (context, child){
return const GetMaterialApp(
debugShowCheckedModeBanner: false,
title: "JobMon",
theme: ThemeData(
scaffoldBackgroundColor: kLight,
iconTheme: IconThemeData(color: kDark),
primaryColor: Colors.grey,
),
home: defaultHome,
);
},
);
}
}
I will really appreciate some help here cause i don’t really know what am doing wrong here.
2
Answers
Remove the
const
keyword fromGetMaterialApp
widget.because of
defaultHome
,kLight
andkDark
are not const, you can’t defineGetMaterialApp
asconst
.