Flutter 如何从右上角而不是左上角启动CustomClipper(ClipPath)

Flutter 如何从右上角而不是左上角启动CustomClipper(ClipPath),flutter,dart,Flutter,Dart,我的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,

我的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;
  }
}
下面是这段代码的图像:

使用
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;
  }
}
class ProfileBarClipper扩展了CustomClipper{
@凌驾
路径getClip(大小){
var path=新路径();
path.moveTo(size.width,0);
path.lineTo(size.width,size.height-50);
var控制点=偏移量(尺寸.宽度-50,尺寸.高度);
var端点=偏移量(size.width/2,size.height);
path.quadraticBezierTo(
ControlPoint.dx、ControlPoint.dy、endPoint.dx、endPoint.dy);
path.lineTo(0,大小.高度);
lineTo(0,0);
返回路径;
}
@凌驾
bool shouldReclip(CustomClipper oldClipper){
返回true;
}
}
输出:


您在路径中使用了方法吗?有道理,但不起作用。在创建var路径之后,我添加了path.moveTo(size.width,0),但它不起作用。问题是该行仍然向左移动
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;
  }
}