【问题标题】:How to notch container with radius from center如何从中心对具有半径的容器开槽
【发布时间】:2021-07-09 12:49:29
【问题描述】:

我想用这个弯曲的缺口来实现这个小部件,但我不能像下图那样从中心用边框半径切割容器。

这是我的目标小部件

这在我的代码中

BottomAppBar(
      shape: CircularNotchedRectangle(),
      child: Container(
        height: MediaQuery.of(context).size.height * .07,
        width: MediaQuery.of(context).size.width,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            end: Alignment.centerRight,
            begin: Alignment.centerLeft,
            colors: [
              blueColor,
              lightColor,
            ],
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.only(left: 16, right: 16),
          child: Row(
            children: [
              Image.asset(
                "assets/images/home.png",
                height: MediaQuery.of(context).size.height * .035,
                width: MediaQuery.of(context).size.width * .3,
              ),
              Spacer(),
              Image.asset(
                "assets/images/cart.png",
                height: MediaQuery.of(context).size.height * .035,
                width: MediaQuery.of(context).size.width * .3,
              ),
            ],
          ),
        ),
      ),
    ),

编辑:在哪种情况下可以使用自定义画家来实现这种情况!

【问题讨论】:

  • 试试这个包。 pub.dev/packages/animated_bottom_navigation_bar 看起来很可定制。但是,如果您需要对设计进行更多控制,则必须为底部栏编写自定义剪辑器。
  • 使用当前配置,在底部应用栏中使用 clipBehaviour: Clip.antiAlias。这将在浮动按钮停靠的地方切出一个缺口。然而,这个缺口是圆形的。
  • @AfridiKayal 这是一个很棒的包,但我无法制作背景颜色渐变
  • 下一个非常适合我的解决方案,谢谢

标签: flutter dart containers radius


【解决方案1】:

在你的位置,我会用那个设计制作一个图像,但没有图标,你稍后用一个堆栈添加图标,所以我解决了复杂的设计。 这不是一个坏主意...

【讨论】:

    【解决方案2】:

    使用自定义剪裁器。 (在 YouTube 上查找自定义剪裁器教程)

    【讨论】:

    • 我正在搜索但无法获得任何帮助...谢谢您
    猜你喜欢
    • 2014-02-28
    • 2014-06-20
    • 2012-10-05
    • 2023-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    相关资源
    最近更新 更多