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大小。