Closed mohamed-seiam closed 1 month ago
I am having same issue did you find any solution
This issue is stale because it has been open for 30 days with no activity.
I have same issue now this time while I am using this package for mobile dev responsive ui and I wondered why so far no one solved. waiting to be solve but dont know how long wiill that take
Same issue
you guys have to wrap your MaterialApp with ScreenUtilInit, follow the docs:
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
//Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
return ScreenUtilInit(
designSize: const Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
// Use builder only if you need to use library outside ScreenUtilInit context
builder: (_ , child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'First Method',
// You can use the library anywhere in the app even in theme
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
),
home: child,
);
},
child: const HomePage(title: 'First Method'),
);
}
}
I got solution. Here is my code,
@override Widget build(BuildContext context) { return ScreenUtilInit( designSize: Size(MediaQuery.of(context).size.width, MediaQuery.of(context).size.height), minTextAdapt: true, splitScreenMode: true, child: MaterialApp( title: Constants.app_name, builder: (context, child) { ScreenUtil.init(context); return Theme( child: Home(), data: ThemeData( textTheme: TextTheme( headline1: TextStyle( fontWeight: FontWeight.bold, fontSize: 11.sp, )), )); }, debugShowCheckedModeBanner: false, ), ); }
This issue is stale because it has been open for 30 days with no activity.
i got the same error
The MaterialApp should be returned From the ScreenUtilInit builder not as a child -- ScreenUtilInit( designSize: const Size(360, 690), minTextAdapt: true, splitScreenMode: true, builder: (_, child) { return MaterialApp( debugShowCheckedModeBanner: false, theme: isDarkMode ? darkThemeManager : lightThemeManager, onGenerateRoute: onGenerateRoute, ); });
have same issue
You must use ScreenUtilInit widget on top of your widget. If they are on the same level, use builder.
Example when use child:
WidgetA(
child: ScreenUtilInit(
child: WidgetB(),
),
)
class WidgetB extends State..Widget {
@override
build(context) {
return Text('', fontSize: 18.sp),
}
}
Example when use builder:
WidgetA(
child: ScreenUtilInit(
builder: (_, __) {
return Text('', fontSize: 18.sp);
},
),
)
Example when use both:
WidgetA(
child: ScreenUtilInit(
builder: (_, child) {
return Container(
width: .2.sw,
child: child,
);
},
// Use child so WidgetB not get built every time .2.sw change
child: WidgetB(),
),
)
i have this error suddenly when i run new application