flutter能設(shè)置圓角的組件:ClipRRect剃执、ClipOval牙咏、CircleAvatar勺良、BoxDecoration BorderRadius.circular往史、BoxDecoration BoxShape.circle
1.ClipRRect:將 child 剪裁為寬高相等的圓角組件,可設(shè)置圓角度數(shù)
new Container(
width: 80,//80或100
height: 80,
child: new ClipRRect(
borderRadius: BorderRadius.circular(40),//圓角度數(shù)
child: Image.network(this.imageUrl),
),
),
2.ClipOval: 將child裁剪為寬高相等的圓角組件(只包括圓形和橢圓形)黍瞧,不可設(shè)置圓角度數(shù)
new Container(
width: 80,//80或100
height: 80,
child:new ClipOval(
child: Image.network(this.imageUrl),
),
),
3.CircleAvatar:只能設(shè)置自身圓形诸尽,不能裁剪child
new Container(
width: 80,//80或100
height: 80,
child: new CircleAvatar(
backgroundImage: NetworkImage(this.imageUrl),
),
),
4.BoxDecoration BorderRadius.circular 設(shè)置自身圓角,不能裁剪child
new Container(
width: 80.0,//100或80
height: 80.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
image: DecorationImage(
image: NetworkImage(this.imageUrl),
)
),
),
4.BoxDecoration BoxShape.circle 只能設(shè)置自身為圓形,不能裁剪child
new Container(
width:80,//80或100
height: 80,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(this.imageUrl),
),
),
)