我试着把容器 colored颜色 作为堆栈放在圆圈头像之上,但问题是 colored颜色 出了圆圈虫

我有以下代码,

                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

如何防止我的 colored颜色 扩大到圆圈宽度?

谢谢

推荐答案

试试这个:

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相关问答推荐

在Flutter 动中绘制ECG图

Build.gradle专线:2个Flutter Flutter

从底部开始固定,然后使其可拖曳Flutter

修复后期变量的抖动皮棉

什么是dart :这只是dart ?

在Fighter中,我如何在窗口的顶部和底部排列Widget?

'Flutter的无效常数值错误

Flutter OpenID Connect无效参数:redirect_uri using Keycloak

在背景图像上排列定位徽标

如何在不注销的情况下刷新Firebase身份验证用户

一个API中有两个不同JSON响应的Flutter 改装问题

DART:如何判断有时可以为空的泛型类型?

Flutter守护进程无法启动

运行调试flutter应用程序时出错:B/BL超出范围(最大+/-128MB)到'';

Flutter列顶部和底部出现不必要的边距问题

Flutter Serverpod 在示例项目上返回 400 错误

如何根据字符串值动态构建和显示小部件?

Flutter 用户过滤器

type '_InternalLinkedHashMap' 不是使用 http 包的'String' 类型的子类型

在自动完成中 Select 值后保持键盘焦点