paint method
Paint this render object and its children.
The canvas provides drawing operations and the offset is the position
in the parent's coordinate system where this render object should paint itself.
Subclasses should override this to paint themselves and call paint on their children with adjusted offsets.
Implementation
@override
void paint(TerminalCanvas canvas, Offset offset) {
if (child == null) {
return;
}
// Clip to prevent the child from painting outside its allocated region.
// The clip is positioned at our global `offset`.
final clipRect = Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height);
final clippedCanvas = canvas.clip(clipRect);
// CRITICAL: The clippedCanvas now has its origin (area.topLeft) set to `offset`.
// We must NOT add `offset` again when painting the child onto the clipped canvas,
// otherwise it will be double-translated and disappear off-screen.
final childLocalOffset = (child!.parentData as BoxParentData).offset;
child!.paintWithContext(clippedCanvas, childLocalOffset);
super.paint(canvas, offset);
}