paint method

  1. @override
void paint(
  1. PaintingContext context,
  2. Offset offset
)
override

Called each time the AnimatedBackground needs to repaint.

The canvas provided in the context is already offset by the amount specified in offset, however the parameter is provided to make the signature of the methods uniform.

Implementation

@override
void paint(PaintingContext context, Offset offset) {
  final Canvas canvas = context.canvas;
  final Paint rectPaint = Paint()..strokeWidth = 1.0;
  for (Rectangle? rect in _rectList!) {
    rectPaint.color = rect!.color!.toColor();
    canvas.drawRect(rect.rect, rectPaint);
  }
}