layout method

  1. @override
PwBox layout(
  1. Context context,
  2. BoxConstraints constraints
)
override

layout API.

Implementation

@override
PwBox layout(Context context, BoxConstraints constraints) {
  final PwBox box = child.layout(
    context,
    BoxConstraints(
      minWidth: minWidth ?? 0,
      maxWidth: maxWidth ?? double.infinity,
      minHeight: minHeight ?? 0,
      maxHeight: maxHeight ?? double.infinity,
    ),
  );
  final double w = constraints.hasBoundedWidth
      ? constraints.maxWidth
      : box.size.width;
  final double h = constraints.hasBoundedHeight
      ? constraints.maxHeight
      : box.size.height;
  final PwSize size = constraints.constrain(PwSize(w, h));
  return ProxyBox(
    size,
    child: box,
    childOffset: alignment
        .resolve(context.textDirection)
        .alongOffset(size, box.size),
  );
}