constrain method

LayoutSize constrain(
  1. LayoutSize size
)

Constrains a size to fit within these constraints.

Returns a new size where width and height are clamped to the min/max bounds of these constraints.

Implementation

LayoutSize constrain(LayoutSize size) {
  final width = size.width.clamp(minWidth, maxWidth);
  final height = size.height.clamp(minHeight, maxHeight);
  return LayoutSize(width, height);
}