positionedChildConstraints method
- Size stackSize
Computes the BoxConstraints the stack layout algorithm would give to this child, given the Size of the stack.
This method should only be called when isPositioned is true for the child.
Implementation
BoxConstraints positionedChildConstraints(Size stackSize) {
assert(isPositioned);
final double? width = switch ((left, right)) {
(final double left?, final double right?) => stackSize.width - right - left,
(_, _) => this.width,
};
final double? height = switch ((top, bottom)) {
(final double top?, final double bottom?) => stackSize.height - bottom - top,
(_, _) => this.height,
};
assert(height == null || !height.isNaN);
assert(width == null || !width.isNaN);
return BoxConstraints.tightFor(
width: width == null ? null : math.max(0.0, width),
height: height == null ? null : math.max(0.0, height),
);
}