参数类型' boxconstraints'可以分配给参数类型' buildContext'

发布于 2025-01-23 13:00:59 字数 585 浏览 2 评论 0原文

我好,我需要代码中的帮助,为什么要遇到此错误,我从另一个项目中复制了代码,但是那里没有错误。

@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(

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遮云壑 2025-01-30 13:00:59

screenutil.init的第一个参数是类型buildContext

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

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

    ScreenUtil.init(
      context,
      deviceSize: Size(screenWidth, screenHeight),
      designSize: const Size(360, 690),
      orientation: Orientation.portrait,
    );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文