performPaint method
Hook for subclasses to implement actual painting.
Implementation
@override
void performPaint(Buffer buffer, Offset offset) {
final sb = widget as ScrollBar;
sb._lastArea = Rect(offset.dx, offset.dy, size.width, size.height);
if (size.width <= 0 || size.height <= 0) return;
final total = sb._totalExtent;
if (total <= 0) return;
if (sb.direction == LayoutDirection.vertical) {
for (var y = 0; y < trackHeight; y++) {
final isThumb = y >= thumbPos && y < thumbPos + thumbHeight;
final style = isThumb ? sb.thumbStyle : sb.trackStyle;
buffer.setAttributes(
offset.dx,
offset.dy + y,
char: isThumb ? sb.thumbChar : sb.trackChar,
fg: style.foreground?.argb ?? 0,
bg: style.background?.argb ?? 0,
modifiers: style.modifiers,
);
}
} else {
for (var x = 0; x < trackHeight; x++) {
final isThumb = x >= thumbPos && x < thumbPos + thumbHeight;
final style = isThumb ? sb.thumbStyle : sb.trackStyle;
buffer.setAttributes(
offset.dx + x,
offset.dy,
char: isThumb ? sb.thumbChar : sb.trackChar,
fg: style.foreground?.argb ?? 0,
bg: style.background?.argb ?? 0,
modifiers: style.modifiers,
);
}
}
}