自定义Clipper Bezier曲线颤振

时间:2020-08-27 13:49:03

标签: flutter flutter-layout

我目前无法绘制贝塞尔曲线。

我现在的输出是: enter image description here

我需要的输出是: enter image description here

在这里我应该添加什么作为贝塞尔值来获得曲线? 自定义裁剪器的代码段为:

    class OnBoardingClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();
    path.moveTo(0.0, size.height * 0.18);
    path.lineTo(0.0, size.height);
    path.lineTo(size.width, size.height);
    path.lineTo(size.width, 0.0);
    return path;
  }

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

P.S。感谢您的阅读和道歉,以防格式错误。 :-)

1 个答案:

答案 0 :(得分:2)

您可以添加一个quadraticBezier,其值例如为(3 / 4 * size.width, size.height * 0.18)(size.width, size.height * 0.05)

代码:

@override
  Path getClip(Size size) {
    var path = Path();
    path.moveTo(0.0, size.height * 0.18);
    path.quadraticBezierTo(
        3 / 4 * size.width, size.height * 0.18, size.width, size.height * 0.05);
    path.lineTo(size.width, size.height);
    path.lineTo(0.0, size.height);
    return path;
  }

结果:

res