ScreenUtil parameters are not defined
I just coppied some lines from the documentation and it seems to be working just fine
https://pub.dev/packages/flutter_screenutil
//ScreenUtil.init(context, 750, height: 1334, allowFontScaling: true);
// ==
ScreenUtil.init(BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height
),
designSize: const Size(750, 1334),
minTextAdapt: true,
);
Comments
-
AzerSD over 1 year
I followed an old flutter tutorial with changing all old dependencies which caused a lot of errors ofc,
I was able to fix all of them only this one:
after changing the version ofscreenutil
from0.4.2
to5.0.2
I got this error: (and other errors that I fixed already)No named parameter with the name 'width'. ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true);
on this line of code
ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true);
I'm a newbie in flutter and dart so even after reading the documentation of
screenutil 5.0.2
I still don't understand what changes I have to do to fix the error.
What I undestood after reading the doc is: that theScreenUtil
object doesn't havewidth
,height
andallowFontScaling
properties anymore. I think now it takes (designSize
,builder
,orientation
andsplitScreenMode
). So I need a way to convert my old line of codeScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true);
to a newer one with the newer properties.
help please. -
Admin over 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.