gpt4 book ai didi

Flutter - 向下画圆弧

转载 作者:IT王子 更新时间:2023-10-29 06:38:06 26 4
gpt4 key购买 nike

我需要画这样的东西:

what I need to achieve

我尝试通过创建 CustomClipper<Path> 来做到这一点并在 ClipPath() 中使用它

这是我的代码:

class ArcBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
child: Container(
width: double.infinity,
height: 400.0,
color: Colors.orange,
),
clipper: RoundedClipper(),
);
}
}

class RoundedClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height);
path.quadraticBezierTo(
size.width / 2,
size.height - 100,
size.width,
size.height
);
path.lineTo(size.width, 0.0);
path.close();
return path;
}

@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}

此代码为我提供了以下输出:

achieved

如您所见,弧线向上,因为我设置了 quadraticaBezierTo() y1属性(property)size.height - 100 ,我希望通过 y1 可以使弧线指向下方属性为size.height + 100但它没有用。

如何实现指向下方的弧度?

最佳答案

这对你有用吗?

@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height-100);
path.quadraticBezierTo(
size.width / 2,
size.height,
size.width,
size.height - 100
);
path.lineTo(size.width, 0.0);
path.close();
return path;
}

关于Flutter - 向下画圆弧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54986608/

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