render method
Renders the widget onto the provided buffer within the specified area.
Implementation
@override
void render(Buffer buffer, Rect area) {
_lastArea = area;
final w = area.width;
final h = area.height;
if (w <= 0 || h <= 0) return;
_initLimits();
final totalSize = direction == LayoutDirection.horizontal ? w : h;
// 1. Calculate raw divider position based on constraints
int dividerPos = _calculateDividerPos(totalSize);
// 2. Solve min/max limits
int minW1 = _origMin1 ?? 0;
int maxW1 = _origMax1 ?? (totalSize - 1);
if (_origMin2 != null) {
maxW1 = min(maxW1, totalSize - _origMin2! - 1);
}
if (_origMax2 != null) {
minW1 = max(minW1, totalSize - _origMax2! - 1);
}
minW1 = minW1.clamp(0, totalSize - 1);
maxW1 = maxW1.clamp(0, totalSize - 1);
if (minW1 > maxW1) minW1 = maxW1;
dividerPos = dividerPos.clamp(minW1, maxW1);
_dividerX = dividerPos;
if (direction == LayoutDirection.horizontal) {
// Render child1
final child1Area = Rect(area.x, area.y, dividerPos, h);
if (dividerPos > 0) {
final vp1 = Viewport(buffer, child1Area);
child1.render(vp1, Rect(0, 0, dividerPos, h));
}
// Render Divider
for (var y = 0; y < h; y++) {
final cell = buffer.getCell(area.x + dividerPos, area.y + y);
if (cell != null) {
cell.char = dividerChar;
cell.style = dividerStyle;
}
}
// Render child2
final child2Width = w - dividerPos - 1;
final child2Area = Rect(area.x + dividerPos + 1, area.y, child2Width, h);
if (child2Width > 0) {
final vp2 = Viewport(buffer, child2Area);
child2.render(vp2, Rect(0, 0, child2Width, h));
}
} else {
// Vertical
// Render child1
final child1Area = Rect(area.x, area.y, w, dividerPos);
if (dividerPos > 0) {
final vp1 = Viewport(buffer, child1Area);
child1.render(vp1, Rect(0, 0, w, dividerPos));
}
// Render Divider
for (var x = 0; x < w; x++) {
final cell = buffer.getCell(area.x + x, area.y + dividerPos);
if (cell != null) {
cell.char = dividerChar;
cell.style = dividerStyle;
}
}
// Render child2
final child2Height = h - dividerPos - 1;
final child2Area = Rect(area.x, area.y + dividerPos + 1, w, child2Height);
if (child2Height > 0) {
final vp2 = Viewport(buffer, child2Area);
child2.render(vp2, Rect(0, 0, w, child2Height));
}
}
}