向 ClipPath 添加背景颜色不起作用

Adding a background color to ClipPath not working

如何向自定义 ClipPath 添加背景颜色?

已尝试以下方法但无效

ClipPath(
    clipper: MyClipper(),
    child: Container(color: Colors.yellowAccent),
)

class MyClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final Path path = Path();
    path.moveTo(0, 0);
    path.lineTo(size.width - 10, 0);
    path.lineTo(size.width, size.height / 2);
    path.lineTo(size.width - 10, size.height);
    path.lineTo(0, size.height);
    path.lineTo(0, 0);
    path.close();

    return path;
  }

  @override
  bool shouldReclip(MyClipper oldClipper) => false;
}

带有颜色的容器可能没有尺寸尝试添加 double.infinity 的高度和宽度或您想要的尺寸