[英]How to create square avatar with rounded corners on flutter?
有很多方法可以实现它,但我只会使用一种。 将ClipRRect()小部件包裹在子小部件周围(这可以是图像或任何其他相关小部件,例如我的示例中使用的 Container)。 然后,将BorderRadius.circular(20.0)
值传递给 ClipRRect() 的borderRadius
属性。 那是创建效果的活动代码行。 在下面查看我的示例:
ClipRRect(
borderRadius: BorderRadius.circular(20.0),//or 15.0
child: Container(
height: 70.0,
width: 70.0,
color: Color(0xffFF0E58),
child: Icon(Icons.volume_up, color: Colors.white, size: 50.0),
),
),
您可以将ClipRRect
与指定BorderRadius
属性一起使用,如下所示:
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10.0)),//add border radius here
child: Image.asset('assets/01.jpg'),//add image location here
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.