ScreenUtil parameters are not defined

268

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,
    );
Share:
268
AzerSD
Author by

AzerSD

yeaaa who cares

Updated on January 02, 2023

Comments

  • AzerSD
    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 of screenutil from 0.4.2 to 5.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 the ScreenUtil object doesn't have width,height and allowFontScaling properties anymore. I think now it takes (designSize, builder, orientation and splitScreenMode). So I need a way to convert my old line of code

    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true);
    

    to a newer one with the newer properties.
    help please.

  • Admin
    Admin over 2 years
    Your 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.