upperBounded method

ViewPort upperBounded(
  1. ViewPort decorated, {
  2. double height = double.infinity,
  3. double width = double.infinity,
})

Provides a ViewPort which ViewPort.width and ViewPort.height values will be upper bounded by the given ones.

Simply said, if the decorated values are bigger than the defined bounds, then bound values are returned (e.g. decorated.width = 500 and width = 400, then 400 will be returned).

width describes the width's upper bound, height - height's upper bound. The bounds are set to double.infinity by default (so if both values were not specified then the resulting object will produce the decorated instance behavior).

final ViewPort vp = const ViewPorts().upperBounded(
  const ViewPorts().fromMediaQueryData(MediaQuery.of(context)),
  width: 1024.0,
);

Implementation

ViewPort upperBounded(
  ViewPort decorated, {
  double height = double.infinity,
  double width = double.infinity,
}) =>
    minOf(decorated, fixed(height: height, width: width));