gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:35:22 26 4
gpt4 key购买 nike

我的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,
),
)

这是此代码的图像:
/image/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;
}
}

输出:

enter image description here

关于flutter - 如何从右上角而不是左上角启动CustomClipper(ClipPath),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61365776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com