computeMaxIntrinsicHeight method Null safety

  1. @override
double computeMaxIntrinsicHeight(
  1. double width

Computes the value returned by getMaxIntrinsicHeight. Do not call this function directly, instead, call getMaxIntrinsicHeight.

Override in subclasses that implement performLayout. Should return the smallest height beyond which increasing the height never decreases the preferred width. The preferred width is the value that would be returned by computeMinIntrinsicWidth for that height.

If the layout algorithm is strictly width-in-height-out, or is width-in-height-out when the height is unconstrained, then this should return the same value as computeMinIntrinsicHeight for the same width.

Otherwise, the width argument should be ignored, and the returned value should be equal to or bigger than the value returned by computeMinIntrinsicHeight.

The width argument will never be negative or null. It may be infinite.

The value returned by this method might not match the size that the object would actually take. For example, a RenderBox subclass that always exactly sizes itself using BoxConstraints.biggest might well size itself bigger than its max intrinsic size.

If this algorithm depends on the intrinsic dimensions of a child, the intrinsic dimensions of that child should be obtained using the functions whose names start with get, not compute.

This function should never return a negative or infinite value.

Be sure to set debugCheckIntrinsicSizes to true in your unit tests if you do override this method, which will add additional checks to help validate your implementation.

See also:


double computeMaxIntrinsicHeight(double width) {
  assert(width >= 0.0);
  // This is equivalent to the min intrinsic height because we cannot provide
  // any greater intrinsic height beyond which increasing the height never
  // decreases the preferred width.
  // When we have an artboard size, the intrinsic min and max height are
  // obviously equivalent and if sized by parent, we can also only return the
  // smallest height constraint (which is 0 in the case of intrinsic height).
  return _intrinsicSizeForConstraints(
          BoxConstraints.tightForFinite(width: width))