Home > Blockchain >  The argument type 'BoxConstraints' can't be assigned to the parameter type 'Buil
The argument type 'BoxConstraints' can't be assigned to the parameter type 'Buil

Time:04-24

I Hello, I need help in my code, why I am getting this error, I copied the code from another project but there is no error there.

@override
 Widget build(BuildContext context) {
dynamic screenWidth = MediaQuery.of(context).size.width;
dynamic screenHeight = MediaQuery.of(context).size.height;
ScreenUtil.init(
    BoxConstraints(maxWidth: screenWidth, maxHeight: screenHeight),
    designSize: const Size(360, 690),
    orientation: Orientation.portrait);

return Scaffold(

enter image description here

CodePudding user response:

ScreenUtil.init's 1st argument is of type BuildContext.

    ScreenUtil.init(
      context,
      deviceSize: Size(screenWidth, screenHeight),
      designSize: const Size(360, 690),
      orientation: Orientation.portrait,
    );
  • Related