问题描述
我想要使用自定义形状的类似形状。
解决方法
您可以使用 ClipPath (https://www.youtube.com/watch?v=oAUebVIb-7s)
顺便说一下,尝试将图像粘贴到 StackOverFlow 问题编辑器中,而不是粘贴外部链接。
,谢谢,我会做到的。
class ProfileImageCustomShape extends CustomClipper<Path> {
@override
getClip(Size size) {
var path = Path();
path.lineTo(0,0);
path.lineTo(0,size.height/1.25);
path.lineTo(size.width/2,size.height);
path.lineTo(size.width,size.height/1.25);
path.lineTo(size.width,0);
return path;
}
@override
bool shouldReclip(CustomClipper oldClipper) {
return false;
}}
// 和 Widget 是
Container(
width: 60,height: 75,child: ClipPath(
clipper: ProfileImageCustomShape(),child: ClipRRect(
borderRadius: BorderRadius.horizontal(
left: Radius.circular(Dimensions.PADDING_SIZE_EXTRA_SMALL),right: Radius.circular(Dimensions.PADDING_SIZE_EXTRA_SMALL)),child: Image.asset(
Images.person_1,fit: BoxFit.fill,width: 100,height: 100,),)),)
,
我刚刚发布了与您的问题类似的内容,请看一下,custom shapes
只使用具有高度和宽度的形状