flutter 如何将边框半径添加到CustomPaint小部件抖动

vuktfyat  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(102)

我尝试使用Custom Paint将边框半径添加到自定义形状的小部件中,但我不知道如何将圆边添加到自定义形状中。
我得到了形状,但没有圆边。

下面是自定义绘画的代码。我如何添加边界半径的边缘。
``

class RPSCustomPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint0 = Paint()
      ..color = const Color.fromARGB(255, 33, 150, 243)
      ..style = PaintingStyle.stroke
      ..strokeWidth = 1.4900000095367432;

    Path path0 = Path();
    path0.moveTo(3.03, 197.85);
    path0.quadraticBezierTo(0.87, 47.28, 1.9, 1.36);
    path0.lineTo(207.0, 2.0);
    path0.lineTo(170.24, 197.9);
    path0.quadraticBezierTo(16.26, 197.13, 3.03, 197.85);
    canvas.drawPath(path0, paint0);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

``

2g32fytz

2g32fytz1#

您可以使用drawRRect()来绘制形状角的边框半径。

canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(size.width / 2 - gap - smallMarkWidth - 15,gap * 8,gap + 70,gap * 5,),Radius.circular(15.0)),backgroundPaint);

相关问题