是否可以使用 Flutter 创建类似的东西? #设计挑战

发布于 2025-01-18 08:37:25 字数 376 浏览 2 评论 0原文

我想知道是否有人可以帮助我使用Trutter设计这样的东西:

“

到目前为止,我尝试在彼此之间创建两个容器,但我不知道如何在中间制作该半圈卡。

同样,如果我们可以将此图像切成两个相等的半部分并为它们分别编写代码,那就太好了。原因是,我需要将数据放入两半,我希望高度是动态的(不是固定的)。

我想使用最佳的设计方法来创建此方法。任何帮助都将不胜感激。

I was wondering If someone could help me design something like this using Flutter :

Design

So far, I've tried creating two containers on top of each other but I do not know how to make that semi circle in the middle of the card.

Also, It would be great If we could cut this image into two equal halves and write code for both of them separately. The reason being, I need to put data into the two halves and I want the height to be dynamic (not fixed).

I want to create this using the best design approach. Any help would be really appreciated.

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

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

发布评论

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

评论(3

温暖的光 2025-01-25 08:37:26

我就是这样做的:

  1. 创建一个列作为具有两个子项的父项。
  2. 创建容器作为第一个子容器。
  3. 创建一个堆栈作为第二个子级。

现在,由于我们将堆栈作为第二个孩子,因此我们可以在其中拥有三个孩子。

  1. 第一个子元素是位于 left:0 和 top:0 的左圆/半圆。
  2. 第二个子元素是位于 right:0 和 top:0 的右圆/半圆
  3. 第三个子元素是没有位置限制的容器。输入 left:0 和 right:0 以将其完全拉伸并适合屏幕。

这将为我们提供所需的结果,而无需使用任何其他复杂的方法。

This is how I did it :

  1. Create a Column as the parent with two children.
  2. Create container as the first child.
  3. Create a stack as the second child.

Now, since we have stack as the second child, we can have three children in it.

  1. First child being the left circle/semi circle positioned at left:0 and top:0.
  2. Second child being the right circle/semi circle positioned at right:0 and top:0
  3. Third child being a container with no positional constraints. Put left:0 and right:0 to stretch it all the way and fit the screen.

This would give us the required results without having to use any other complicated way.

南巷近海 2025-01-25 08:37:25

使用 CustomPaint,请在此处了解更多信息, fluttershapemaker 可以帮助您轻松完成此操作,只需绘制它或将此 SVG 转换为 CustomPaint 代码。

Use CustomPaint, read more here, and fluttershapemaker can help you do it easily by drawing it or converting this SVG to CustomPaint code.

蓦然回首 2025-01-25 08:37:25

有几种方法可以做到这一点,

  1. 您可以使用普通的矩形容器,并在左侧和右侧给topRight和bottomRight高边框半径,而不是制作圆形容器,您可以在topLeft和右侧给容器高边框半径左下角。代码看起来像
Container(height:MediaQuery.of(context).size.height,aligment:Alignment.center, child:Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      Container(
        decoration: const BoxDecoration(
          borderRadius: BorderRadius.only(
            topRight: Radius.circular(100),
            bottomRight: Radius.circular(100),
          ),
        ),
      ),
      Container(
        decoration: const BoxDecoration(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(100),
            bottomLeft: Radius.circular(100),
          ),
        ),
      )
    ]),),
  1. 如果你想坚持创建一个圆圈,你可以添加到堆栈上的圆圈并将它们放置在左和右的负值上。从而按照您想要的方式切割圆圈。

我希望这有帮助

There is a couple of ways you can do that

  1. Instead of making a circe container you can use a normal rectangle container and give topRight and bottomRight high borderRadius on the left side and on the right side you would give the container high border radius on topLeft and bottomLeft. the code will look something like
Container(height:MediaQuery.of(context).size.height,aligment:Alignment.center, child:Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
      Container(
        decoration: const BoxDecoration(
          borderRadius: BorderRadius.only(
            topRight: Radius.circular(100),
            bottomRight: Radius.circular(100),
          ),
        ),
      ),
      Container(
        decoration: const BoxDecoration(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(100),
            bottomLeft: Radius.circular(100),
          ),
        ),
      )
    ]),),
  1. If you want to stick with creating a circle you can add to circles on a stack and position them on a negative value of left and right. resulting in cutting the circle how ever you want.

I hope this helps

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