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, constraints.loosen());
  final double w = widthFactor != null
      ? box.size.width * widthFactor!
      : constraints.hasBoundedWidth
      ? constraints.maxWidth
      : box.size.width;
  final double h = heightFactor != null
      ? box.size.height * heightFactor!
      : constraints.hasBoundedHeight
      ? constraints.maxHeight
      : box.size.height;
  final PwSize size = constraints.constrain(PwSize(w, h));
  final Alignment resolved = alignment.resolve(context.textDirection);
  return ProxyBox(
    size,
    child: box,
    childOffset: resolved.alongOffset(size, box.size),
  );
}