layout method
void
layout(
- Context context,
- BoxConstraints constraints, {
- bool parentUsesSize = false,
override
First widget pass to calculate the children layout and bounding box
Implementation
@override
void layout(Context context, BoxConstraints constraints,
{bool parentUsesSize = false}) {
final shrinkWrapWidth =
widthFactor != null || constraints.maxWidth == double.infinity;
final shrinkWrapHeight =
heightFactor != null || constraints.maxHeight == double.infinity;
if (child != null) {
child!.layout(context, constraints.loosen(), parentUsesSize: true);
assert(child!.box != null);
box = constraints.constrainRect(
width: shrinkWrapWidth
? child!.box!.width * (widthFactor ?? 1.0)
: double.infinity,
height: shrinkWrapHeight
? child!.box!.height * (heightFactor ?? 1.0)
: double.infinity);
child!.box = alignment.inscribe(child!.box!.size, box!);
} else {
box = constraints.constrainRect(
width: shrinkWrapWidth ? 0.0 : double.infinity,
height: shrinkWrapHeight ? 0.0 : double.infinity);
}
}