【问题标题】:A quick question about responsiveness in Flutter一个关于 Flutter 响应性的快速问题
【发布时间】:2021-10-01 22:24:35
【问题描述】:

我几乎完成了我的应用程序的实现,现在我正在使它更具响应性,但我发现了一个问题。我正在使用三个模拟器(Pixel 2、Pixel 4 和 Nexus 4)以及我的手机(Galaxy S10+)。这是问题:

左边第一个是我的模拟器(Pixel 4),右边第二个是我的手机(S10+)。看到问题了吗?位置以某种方式发生了变化,两者具有相同的纵横比(19:9)和默认分辨率(1080x2280)。那么这里发生了什么?我将只为一张图片添加代码(带有放大镜的那个球体,如果适用于一张,其余的都可以):

 body: LayoutBuilder(builder: (context, constraints) {
        return Container(
          child: SingleChildScrollView(
            child: Stack(children: [
              Container(
                  width: constraints.maxWidth,
                  height: constraints.maxHeight <= 592
                      ? constraints.maxHeight * 3.6
                      : constraints.maxHeight * 2.7,
                  decoration: BoxDecoration(
                      image: DecorationImage(
                          image: NetworkImage(
                              'https://i.imgur.com/SdLahrV.png'),
                          fit: BoxFit.cover))),
              Wrap(
                children: [
                  Container(
                    margin: EdgeInsets.only(
                        left: constraints.maxWidth >= 380 &&
                                constraints.maxHeight >= 500
                            ? constraints.maxWidth * 0.02
                            : constraints.maxWidth * 0.04,
                        top: constraints.maxHeight >= 592
                            ? constraints.maxHeight * 0.22
                            : constraints.maxHeight * 0.35),
                    height: constraints.maxHeight * 0.14,
                    width: constraints.maxWidth * 0.24,
                    child: GestureDetector(
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                            builder: (context) => TelaConhecMangue_(),
                          ),
                        );
                      },
                      child: Image(
                          image: NetworkImage(
                              'https://i.imgur.com/HmwwpOb.gif')),
                    ),
                  ),
                ],
              ),
            ],
           ),
          ),
        );
       }
      );

提前致谢

【问题讨论】:

    标签: flutter android-emulator flutter-layout responsiveness


    【解决方案1】:

    在这种情况下,媒体查询可能会有所帮助。

    【讨论】:

    • 我没有去媒体查询,但我会试一试。我认为 constraintedBox 和 MediaQuery 做同样的事情,这就是为什么我还没有使用它。谢谢
    猜你喜欢
    • 2019-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 2020-02-11
    • 2010-12-12
    相关资源
    最近更新 更多