paint method

void paint(
  1. Canvas canvas,
  2. Rect rect,
  3. Color color
)

Paints this screen's dots in rect, clipped to it. The dots go down in device pixels so that every one of them lands on the same part of a pixel: no drift, no moire.

Implementation

void paint(Canvas canvas, Rect rect, Color color) {
  if (rect.isEmpty || color.a == 0) return;
  canvas.save();
  canvas.clipRect(rect);
  canvas.translate(rect.left, rect.top);
  canvas.scale(1 / dpr);
  canvas.drawRawPoints(
    ui.PointMode.points,
    _deviceCentres(rect.size),
    Paint()
      ..color = color
      ..strokeCap = StrokeCap.round
      ..strokeWidth = radius * dpr * 2,
  );
  canvas.restore();
}