performLayout method
Hook for subclasses to perform layout within the given constraints.
Implementation
@override
Size performLayout(BoxConstraints constraints) {
final split = widget as SplitPane;
final w = constraints.maxWidth == BoxConstraints.infinity
? 20
: constraints.maxWidth;
final h = constraints.maxHeight == BoxConstraints.infinity
? 10
: constraints.maxHeight;
split._initLimits();
final totalSize = split.direction == LayoutDirection.horizontal ? w : h;
int dividerPos = _calculateDividerPos(totalSize);
int minW1 = split._origMin1 ?? 0;
int maxW1 = split._origMax1 ?? (totalSize - 1);
if (split._origMin2 != null) {
maxW1 = min(maxW1, totalSize - split._origMin2! - 1);
}
if (split._origMax2 != null) {
minW1 = max(minW1, totalSize - split._origMax2! - 1);
}
minW1 = minW1.clamp(0, totalSize - 1);
maxW1 = maxW1.clamp(0, totalSize - 1);
if (minW1 > maxW1) minW1 = maxW1;
dividerPos = dividerPos.clamp(minW1, maxW1);
split._dividerX = dividerPos;
if (split.direction == LayoutDirection.horizontal) {
if (childElement1 != null) {
childElement1!.relativeOffset = Offset.zero;
if (dividerPos > 0) {
childElement1!.layout(BoxConstraints.tight(Size(dividerPos, h)));
}
}
if (childElement2 != null) {
childElement2!.relativeOffset = Offset(dividerPos + 1, 0);
final child2Width = w - dividerPos - 1;
if (child2Width > 0) {
childElement2!.layout(BoxConstraints.tight(Size(child2Width, h)));
}
}
} else {
if (childElement1 != null) {
childElement1!.relativeOffset = Offset.zero;
if (dividerPos > 0) {
childElement1!.layout(BoxConstraints.tight(Size(w, dividerPos)));
}
}
if (childElement2 != null) {
childElement2!.relativeOffset = Offset(0, dividerPos + 1);
final child2Height = h - dividerPos - 1;
if (child2Height > 0) {
childElement2!.layout(BoxConstraints.tight(Size(w, child2Height)));
}
}
}
return constraints.constrain(Size(w, h));
}