drawPath method

void drawPath(
  1. UiPaint paint,
  2. Canvas uiCanvas
)

Draws the path on the given canvas with the specified paint.

This method handles both solid and dashed lines.

Implementation

void drawPath(UiPaint paint, ui.Canvas uiCanvas) {
  List<double>? dasharray = paint.getStrokeDasharray();
  if (dasharray != null && dasharray.length >= 2) {
    drawDash(paint, uiCanvas);
    return;
  }
  if (!_path.getBounds().overlaps(uiCanvas.getLocalClipBounds())) return;
  //    if (paint.isFillPaint()) {
  uiCanvas.drawPath(_path, paint.expose());
  return;
  //  }

  // https://github.com/flutter/flutter/issues/78543#issuecomment-885090581
  _points.forEachIndexed((int idx, Pointinfo point) {
    if (idx > 0 && !point.start) {
      // do NOT draw a line TO a new start point
      uiCanvas.drawLine(_points[idx - 1].offset, point.offset, paint.expose());
    }
  });
}