扑来中不同设备大小的错误或不兼容

发布于 2025-02-12 06:15:03 字数 1020 浏览 0 评论 0原文

正如我在代码中所述,我将介质的尺寸提供给小部件的大小,但是尽管如此,尽管如此,诸如不同设备上的图像之类的不兼容性,或者我遇到了溢出错误。解决方案是什么?我应该如何尺寸的小部件以及内部按钮和图像之类的东西?

“在此处输入映像说明”

被切断的文本:

”在此处输入图像描述

  Padding(
          padding: const EdgeInsets.only(top: 20.0, right: 30),
          child: Container(
            height: MediaQuery.of(context).size.height * 0.02,
            width: MediaQuery.of(context).size.width * 0.23,
            child: ElevatedButton(
              onPressed: () {},
              style: ElevatedButton.styleFrom(
                primary: back_color,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(25),
                ),
              ),
              child: const Text(
                'Discover',
                style: TextStyle(fontSize: 15, color: Colors.black),
              ),
            ),
          ),
        ),

As I stated in the code, I give the widget sizes with MediaQuery, but despite this, there are incompatibilities like the images on different devices or I get an Overflow error. What is the solution to this? How should I size my widgets and things like buttons and images inside?

enter image description here

The text being cut off:

enter image description here

  Padding(
          padding: const EdgeInsets.only(top: 20.0, right: 30),
          child: Container(
            height: MediaQuery.of(context).size.height * 0.02,
            width: MediaQuery.of(context).size.width * 0.23,
            child: ElevatedButton(
              onPressed: () {},
              style: ElevatedButton.styleFrom(
                primary: back_color,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(25),
                ),
              ),
              child: const Text(
                'Discover',
                style: TextStyle(fontSize: 15, color: Colors.black),
              ),
            ),
          ),
        ),

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

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

发布评论

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

评论(1

Bonjour°[大白 2025-02-19 06:15:06

为避免文本被切断,您可以包装 fittedbox() 在您的text() widget上:

Padding(
        padding: const EdgeInsets.only(top: 20.0, right: 30),
        child: Container(
          height: MediaQuery.of(context).size.height * 0.02,
          width: MediaQuery.of(context).size.width * 0.23,
          child: ElevatedButton(
            onPressed: () {},
            style: ElevatedButton.styleFrom(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(25),
              ),
            ),
            child: FittedBox(
              fit: BoxFit.fitWidth,
              child: const Text(
                'Discover',
                style: TextStyle(fontSize: 15, color: Colors.black),
              ),
            ),
          ),
        ));

在这里是Google Team的YouTube视频,on fittitesbox()) 。

To avoid the text from being cut off, you can wrap FittedBox() on your Text() widget:

Padding(
        padding: const EdgeInsets.only(top: 20.0, right: 30),
        child: Container(
          height: MediaQuery.of(context).size.height * 0.02,
          width: MediaQuery.of(context).size.width * 0.23,
          child: ElevatedButton(
            onPressed: () {},
            style: ElevatedButton.styleFrom(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(25),
              ),
            ),
            child: FittedBox(
              fit: BoxFit.fitWidth,
              child: const Text(
                'Discover',
                style: TextStyle(fontSize: 15, color: Colors.black),
              ),
            ),
          ),
        ));

Here is a YouTube video from the Google team on FittedBox().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文