constrainDimensions method Null safety

Size constrainDimensions(
  1. double width,
  2. 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 Size(constrainWidth(width), constrainHeight(height));
}