Size constrain(Size size)

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

Source

Size constrain(Size size) {
  Size result = new Size(constrainWidth(size.width), constrainHeight(size.height));
  assert(() {
    if (size is _DebugSize)
      result = new _DebugSize(result, size._owner, size._canBeUsedByParent);
    return true;
  });
  return result;
}