constrain method

Size constrain(
  1. Size size

Returns the size that both satisfies the constraints and is as close as possible to the given size.

See also:

  • constrainDimensions, which applies the same algorithm to separately provided widths and heights.


Size constrain(Size size) {
  Size result = Size(constrainWidth(size.width), constrainHeight(size.height));
  assert(() {
    result = _debugPropagateDebugSize(size, result);
    return true;
  return result;