paint method
Implementation
@override
String paint() {
if (children.isEmpty) return '';
final targetWidth = size.width.toInt();
final targetHeight = size.height.toInt();
if (targetWidth == 0 || targetHeight == 0) return '';
final canvas = Canvas(targetWidth, targetHeight);
final bgStyle = const UvStyle();
var isFirstChild = true;
for (final child in children) {
final content = child.paint();
final childWidth = child.size.width.toInt();
final childHeight = child.size.height.toInt();
final x = child.offset.dx.toInt();
final y = child.offset.dy.toInt();
if (isFirstChild &&
x == 0 &&
y == 0 &&
childWidth == targetWidth &&
childHeight == targetHeight) {
// First child fills the entire canvas — draw StyledString directly
// onto the main canvas, skipping the temp canvas + cell-by-cell copy.
StyledString(content).draw(canvas, canvas.bounds());
} else {
_drawStyledContent(
canvas,
content,
x,
y,
bgStyle,
transparent: !isFirstChild,
);
}
isFirstChild = false;
}
var result = canvas.render();
result = _padToStackSize(result, targetWidth, targetHeight);
return result;
}