【发布时间】: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