如何用ClipPath编辑容器顶部的Flutter?

mgdq6dx1  于 2022-12-30  发布在  Flutter
关注(0)|答案(1)|浏览(93)

在我的flutter中,我有以下代码来编辑容器:

path.lineTo(x, size.height / 3);
      path.cubicTo(x + increment / 9, size.height / 2 + 100, x + increment,
          size.height, x + increment, size.height);

这将导致this
然而,顶部保持直线,我怎么能增加弯曲的顶部太多?
我尝试使用path.moveTo,但结果是相同的形状。
完整代码:

class WavyPages extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();
    path.lineTo(0, size.height);
    var x = 0.0;
    var numberOfWaves = 1;
    var increment = size.width / numberOfWaves;

      path.lineTo(x, size.height / 3);
      path.cubicTo(x + increment / 9, size.height / 2 + 100, x + increment,size.height, x + increment, size.height);

    path.lineTo(size.width, 0);
    path.lineTo(0, 0);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(WavyPages oldClipper) => true;
}
okxuctiv

okxuctiv1#

对于最上面的部分,你可以试试我的代码:

class WavyPages extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();
    var x = 0.0;
    var numberOfWaves = 1;
    var increment = size.width / numberOfWaves;
    path.moveTo(size.width, 0);
    path.cubicTo(size.width,0,size.width-increment,0,x,size.height / 2);
      
      path.cubicTo(0, size.height / 2 + 100, x + increment,size.height, x + increment, size.height);

    path.lineTo(size.width, 0);
    path.lineTo(0, 0);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(WavyPages oldClipper) => true;
}

告诉我这是不是你想要的...

相关问题