layout method
Performs the actual layout of this child within the given constraints.
This method calculates and sets the child's size and position based on
the provided constraints and the child's layout data. After calling this,
the child's size
and offset
properties will be valid.
Implementation
@override
void layout(
LayoutOffset offset,
LayoutSize size,
OverflowBounds overflowBounds,
) {
double maxScrollX = parent.contentSize.width - parent.viewportSize.width;
double maxScrollY = parent.contentSize.height - parent.viewportSize.height;
maxScrollX = max(0.0, maxScrollX);
maxScrollY = max(0.0, maxScrollY);
(renderBox.parentData as LayoutBoxParentData).offset =
offsetFromLayoutOffset(offset);
renderBox.layout(
(renderBox.parentData as LayoutBoxParentData).needLayoutBox
? WrappedLayoutConstraints(
size: sizeFromLayoutSize(size),
offset: offsetFromLayoutOffset(offset),
scrollX: parent.scrollOffsetX,
scrollY: parent.scrollOffsetY,
maxScrollX: maxScrollX,
maxScrollY: maxScrollY,
contentSize: sizeFromLayoutSize(parent.contentSize),
viewportSize: sizeFromLayoutSize(parent.viewportSize),
horizontalUserScrollDirection: parent.horizontalAxisDirection,
verticalUserScrollDirection: parent.verticalAxisDirection,
overflowBounds: overflowBounds,
)
: BoxConstraints.tight(
sizeFromLayoutSize(size),
),
parentUsesSize: true,
);
}