clearRect method

  1. @override
void clearRect(
  1. num x,
  2. num y,
  3. num width,
  4. num height, {
  5. PStyle? style,
})
override

Clears a part of the canvas.

  • Applies style if provided.

Implementation

@override
void clearRect(num x, num y, num width, num height, {PStyle? style}) {
  var xd = transform.xD(x);
  var yd = transform.yD(y);

  xd = canvasXD(xd);
  yd = canvasYD(yd);

  final widthD = canvasXD(width);
  final heightD = canvasYD(height);

  var paint = style?.asPaintFill;

  _widgetPainter.addOp((canvas, size) {
    paint ??= Paint()
      ..style = PaintingStyle.fill
      ..color = Colors.white;

    var rect = Rect.fromLTWH(xd, yd, widthD, heightD);
    canvas.drawRect(rect, paint!);
  });
}