CircleAvatar 圆形头像组件

CircleAvatar是Flutter中的一个用于展示圆形头像的组件,其使用简单,只需设置backgroundImage和radius属性。虽然不能直接设置大小,但可以通过包裹在Container内调整尺寸。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CircleAvatar 圆形头像组件

CircleAvatar是一个圆形Image,常用来显示用户Icon,比Android中实现圆形ImageView简单多了。构造方法如下:

  const CircleAvatar({
    Key key,
    this.child,
    this.backgroundColor,//背景色,相当于加载中或加载失败的占位图
    this.backgroundImage,//背景图,相当于加载中或加载失败的占位图
    this.foregroundColor,//前景色,
    this.radius,
    this.minRadius,
    this.maxRadius,
  }) : assert(radius == null || (minRadius == null && maxRadius == null)),
       super(key: key);

CircleAvatar用法也很简单,设置backgroundImage和radius就会显示出一个圆形Image效果。

 new Container(
              width: 80,
              height: 80,
              child: new CircleAvatar(
                backgroundImage: NetworkImage(
                    'http://n.sinaimg.cn/sports/2_img/upload/cf0d0fdd/107/w1024h683/20181128/pKtl-hphsupx4744393.jpg'),
                radius: 20,
              ),
            ),
            new CircleAvatar(backgroundImage:AssetImage('image/test_icon.jpg'),
              radius: 20,)

由于CircleAvatar不能设置大小,所以可以在外面包一层Container来设置CircleAvatar大小。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值