我需要在画布上绘制两条线,第一行从屏幕的顶部开始,第二行从屏幕的75%之后开始。我尝试下面的代码,但是当我绘制第二条线时,它会影响第一条线strokeWidth。如何创建两条单独的线:
void paint(Canvas canvas, Size size) {
final Paint firstPaint = Paint();
firstPaint.color = const Color.fromARGB(255, 236, 0, 140);
final Path firstPath = Path();
firstPath.lineTo(0, 30.0);
firstPath.lineTo(size.width, 0);
canvas.drawPath(firstPath, firstPaint);
final Offset center = Offset(0.0, size.height / 2 * 1.45);
final Paint secondPaint = Paint();
secondPaint.style = PaintingStyle.fill;
secondPaint.color = const Color.fromARGB(255, 236, 0, 140);
final Path secondPath = Path();
firstPath.lineTo(0, 80.0);
secondPath.lineTo(size.width, 0);
secondPath.addPath(firstPath, center);
canvas.drawPath(secondPath, secondPaint);
}
答案 0 :(得分:0)
我猜这是因为您将两条路径连接在一起,然后进行了重新绘制。 也许以下将解决它。
Blob