layout method
layout API.
Implementation
@override
PwBox layout(Context context, BoxConstraints constraints) {
final Widget? kid = child;
final PwBox? box = kid?.layout(context, constraints);
final PwSize raw = box?.size ?? size ?? PwSize.zero;
final bool fillWidth =
size == null && kid == null && constraints.hasBoundedWidth;
final bool fillHeight =
size == null && kid == null && constraints.hasBoundedHeight;
final PwSize painted = constraints.constrain(
PwSize(
fillWidth ? constraints.maxWidth : raw.width,
fillHeight ? constraints.maxHeight : raw.height,
),
);
return _CustomPaintBox(painted, box, painter, foregroundPainter);
}