constrainDimensions method

Size constrainDimensions (double width, double height)

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

When you already have a Size, prefer constrain, which applies the same algorithm to a Size directly.

Implementation

Size constrainDimensions(double width, double height) {
  return new Size(constrainWidth(width), constrainHeight(height));
}