layout method

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

layout API.

Implementation

@override
PwBox layout(Context context, BoxConstraints constraints) {
  var w = constraints.maxWidth;
  var h = w / aspectRatio;
  if (h > constraints.maxHeight) {
    h = constraints.maxHeight;
    w = h * aspectRatio;
  }
  final PwSize size = constraints.constrain(PwSize(w, h));
  final PwBox box = child.layout(context, BoxConstraints.tight(size));
  return ProxyBox(size, child: box);
}