简体   繁体   English

以下线框的响应式 UI 应使用哪些小部件?

[英]Which widgets should be used for responsive UI of the following wireframe?

What widgets should be used to display 3 cartoons at the bottom of this picture and the text at the center responsively for different screen sizes?对于不同的屏幕尺寸,应该使用哪些小部件在这张图片的底部显示 3 个卡通,并在中心显示文本?

在此处输入图像描述

Row with spaceEvenlyRow spaceEvenly

           return Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                //your images
              ],
            );

https://flutteragency.com/how-to-set-space-between-elements-in-flutter/ https://flutteragency.com/how-to-set-space-between-elements-in-flutter/

There are many ways to do this.有很多方法可以做到这一点。 It will also depend on what responsive behavior you are looking for.它还取决于您正在寻找的响应行为。 I hope, I understood your specific requirements.我希望,我了解您的具体要求。

Here is a solution:这是一个解决方案:

在此处输入图像描述

class Page extends StatelessWidget {
  const Page({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AspectRatio(
        aspectRatio: 16 / 9,
        child: Container(
          decoration: const BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/images/bg.png"),
              fit: BoxFit.cover,
            ),
          ),
          child: Stack(children: [
            Center(
              child: FractionallySizedBox(
                widthFactor: .4,
                child: FittedBox(
                  fit: BoxFit.fitWidth,
                  child: Text(
                    'Headline text',
                    style: GoogleFonts.chewy(
                      textStyle: const TextStyle(
                        color: Colors.white,
                        letterSpacing: .5,
                      ),
                    ),
                  ),
                ),
              ),
            ),
            Container(
              alignment: const Alignment(0, .75),
              child: FractionallySizedBox(
                widthFactor: .8,
                heightFactor: .3,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Image.asset("assets/images/img1.png"),
                    Image.asset("assets/images/img2.png"),
                    Image.asset("assets/images/img3.png"),
                  ],
                ),
              ),
            )
          ]),
        ),
      ),
    );
  }
}

In this solution,在这个解决方案中,

  1. I use a main Container that will have your image as background.我使用一个主Container ,它将您的图像作为背景。
  2. I then use a Stack to position the headline and the images.然后我使用一个Stack来 position 标题和图像。
  3. The headline is Center ed and defined as a FittedBox inside a FractionallySizedBox .标题是Center ed,并定义为FractionallySizedBox内的FittedBox This allows me to have responsivity for the headline too.这也让我对标题也有责任感。
  4. Finally, for the list of images, I used a FractionallySizedBox to size the list and an aligned Container to position it within the stack.最后,对于图像列表,我使用了FractionallySizedBox来调整列表的大小,并在堆栈中使用对齐的Container到 position 它。 The images are then spread thanks to the use of MainAxisAlignment.spaceBetween .然后通过使用MainAxisAlignment.spaceBetween传播图像。

So, as you see, I used the following widgets to responsively size and position my Widgets:因此,如您所见,我使用以下小部件来响应大小和 position 我的小部件:

  • Position Position
    • Center
    • Container with the alignment property具有alignment属性的Container
  • Size尺寸
    • FractionallySizedBox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter下面的设计应该使用哪个widget? - Which widget should be used for following design in flutter? 响应式 Flutter 时,多个小部件在抽屉小部件中使用相同的 GlobalKey - Multiple widgets used the same GlobalKey in Drawer Widgets when Responsive Flutter 小部件的“const”是否只需要在有状态小部件中使用? - Should "const" for widgets need to be used only in stateful widgets? 我应该将哪些小部件设为有状态? - Which Widgets should I make stateful? 完成小部件树时抛出以下断言:多个小部件使用相同的 GlobalKey flutter - The following assertion was thrown while finalizing the widget tree: Multiple widgets used the same GlobalKey flutter 应该使用什么小部件在 Flutter 中的两个切换按钮之间创建一个 TextField? - Whats widgets should be used for creating one TextField between two toggle buttons in Flutter? 响应式材质按钮小部件颤动 - Responsive Material Button widgets flutter CachedNetworkImage 和 CachedNetworkImageProvider 有什么区别? 应该分别用在什么情况下? - What is the difference between CachedNetworkImage and CachedNetworkImageProvider? Which case should each be used in? 应该使用 List 的哪种方法将两个匹配的单词分配给 value - Which method of List should be used to assign two matching words to the value 多个小部件使用相同的 GlobalKey - Multiple widgets used the same GlobalKey
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM