paintLine static method

void paintLine(
  1. Canvas canvas,
  2. double startX,
  3. double endX, {
  4. Offset center = const Offset(0, 0),
  5. Color color = Colors.red,
  6. double rotateAngle = 0,
  7. double strokeWidth = 1,
})

绘制线段

Implementation

static void paintLine(
  Canvas canvas,
  double startX,
  double endX, {
  Offset center = const Offset(0, 0),
  Color color = Colors.red,
  double rotateAngle = 0,
  double strokeWidth = 1,
}) {
  canvas.save();
  canvas.translate(center.dx, center.dy);
  canvas.rotate(rotateAngle * rad);
  canvas.drawLine(
      Offset(startX, 0),
      Offset(endX, 0),
      Paint()
        ..color = color
        ..strokeCap = StrokeCap.round
        ..style = PaintingStyle.stroke
        ..strokeWidth = strokeWidth);
  canvas.restore();
}