performPaint method

  1. @override
void performPaint(
  1. Buffer buffer,
  2. Offset offset
)
override

Hook for subclasses to implement actual painting.

Implementation

@override
void performPaint(Buffer buffer, Offset offset) {
  if (size.width <= 0 || size.height <= 0) return;

  final hasOverflow = _overflowLeft > 0 || _overflowRight > 0;
  if (hasOverflow) {
    buffer.pushClip(
      Rect(offset.dx.toInt(), offset.dy.toInt(), size.width, size.height),
    );
  }

  final row = widget as Row;
  if (row.backgroundChar != null) {
    final char = row.backgroundChar!;
    final style = row.backgroundStyle ?? Style.empty;
    buffer.fillRect(
      Rect(offset.dx.toInt(), offset.dy.toInt(), size.width, size.height),
      char: char,
      fg: style.foreground?.argb ?? 0,
      bg: style.background?.argb ?? 0,
      modifiers: style.modifiers,
    );
  }

  for (final child in childElements) {
    child.paint(buffer, offset + child.relativeOffset);
  }

  if (_overflowLeft > 0 || _overflowRight > 0) {
    final tapeWidth = size.width < 3 ? size.width : 3;

    if (_overflowLeft > 0) {
      final bounds = Rect(
        offset.dx.toInt(),
        offset.dy.toInt(),
        tapeWidth,
        size.height,
      );
      buffer.drawCautionTape(bounds, offset.dx.toInt(), offset.dy.toInt());
    }

    if (_overflowRight > 0) {
      final bounds = Rect(
        (offset.dx + size.width - tapeWidth).toInt(),
        offset.dy.toInt(),
        tapeWidth,
        size.height,
      );
      buffer.drawCautionTape(bounds, bounds.left, offset.dy.toInt());
    }
  }

  if (hasOverflow) {
    buffer.popClip();
  }
}