我的CustomClipper从左上角开始,但是,我希望它从右上角开始。
这是我的代码:
快船队:
class ProfileBarClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = new Path();
path.lineTo(0, size.height - 50);
var controllPoint = Offset(50, size.height);
var endPoint = Offset(size.width / 2, size.height);
path.quadraticBezierTo(
controllPoint.dx, controllPoint.dy, endPoint.dx, endPoint.dy);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}
ProfileBarClipper()的用法:
ClipPath(
clipper: ProfileBarClipper(),
child: Container(
color: Colors.white,
height: 200,
),
)
这是此代码的图像:
https://i.stack.imgur.com/rVsL3.png
最佳答案
使用moveTo
。
像这样。
var path = new Path();
path.moveTo(size.width,0); // (size.width, 0) means top right
更新:检查一下...
class ProfileBarClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = new Path();
path.moveTo(size.width, 0);
path.lineTo(size.width, size.height - 50);
var controllPoint = Offset(size.width-50, size.height);
var endPoint = Offset(size.width / 2, size.height);
path.quadraticBezierTo(
controllPoint.dx, controllPoint.dy, endPoint.dx, endPoint.dy);
path.lineTo(0, size.height);
path.lineTo(0, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}
输出: