gpt4 book ai didi

flutter - 如何使用 Stack 进入 CircleAvatar

转载 作者:行者123 更新时间:2023-12-05 05:35:25 25 4
gpt4 key购买 nike

我正在尝试将 Container 颜色作为 Stack 放在圆形头像上方,但问题是颜色超出了圆孔

我有以下代码,

                IntrinsicWidth(
child: Stack(
alignment: Alignment.bottomCenter,
children: [
const CircleAvatar(
radius: 50,
),
Container(
color: Colors.yellowAccent,
height: 30,
)
],
),
)

我得到以下输出

enter image description here

但我需要如下所示的输出

enter image description here

如何防止我的颜色扩展到圆宽度

谢谢

最佳答案

试试这个:

CircleAvatar(
backgroundColor: Colors.yellow,
radius: 100,
child: Container(
alignment: Alignment.bottomCenter,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Container(
height: 40,
width: double.infinity,
color: Colors.red,
),
),
)

enter image description here

关于flutter - 如何使用 Stack 进入 CircleAvatar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73524695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com