calculateFixedChildSizes method
Implementation
Size calculateFixedChildSizes(ChildLayouter layoutChild) {
var allocatedWidth = 0.0;
var allocatedHeight = 0.0;
double maxChildExtent = _direction == Axis.horizontal
? constraints.maxWidth
: constraints.maxHeight;
RenderBox? child = firstChild;
// iterate through children
while (child != null) {
var data = getParentData(child.parentData);
var model = data?.model;
// perform layout
if (data != null && model != null) {
// assign flex value
_setChildFlex(data, model);
// layout child
if (data.flex == null) {
// get layout constraints
var childConstraints =
_getChildLayoutConstraints(child, model, maxChildExtent);
// calculate the child's size by performing
// a dry layout. We use LocalBoxConstraints in order to
// override isTight, which is used in Layout() to determine if a
// child size change forces a parent to resize.
doLayout(child, childConstraints, layoutChild);
// set width
allocatedWidth = _direction == Axis.horizontal
? (allocatedWidth + (child.size.width))
: max(allocatedWidth, (child.size.width));
// set height
allocatedHeight = _direction == Axis.horizontal
? max(allocatedHeight, (child.size.height))
: allocatedHeight + (child.size.height);
}
}
else {
// calculate the child's size by performing
// a dry layout. We use LocalBoxConstraints in order to
// override isTight, which is used in Layout() to determine if a
// child size change forces a parent to resize.
doLayout(child, constraints, layoutChild);
// set width
allocatedWidth = _direction == Axis.horizontal
? (allocatedWidth + (child.size.width))
: max(allocatedWidth, (child.size.width));
// set height
allocatedHeight = _direction == Axis.horizontal
? max(allocatedHeight, (child.size.height))
: allocatedHeight + (child.size.height);
}
// get next child
child = childAfter(child);
}
return Size(allocatedWidth, allocatedHeight);
}