computeMaxIntrinsicWidth method

  1. @override
double computeMaxIntrinsicWidth(
  1. double height
)
override

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

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

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

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

The height 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:

Implementation

@override
double computeMaxIntrinsicWidth(double height) {
  resolvePadding();
  return _getIntrinsicCrossAxis((child) {
    final childHeight = math.max<double>(0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
    return child.getMaxIntrinsicWidth(childHeight) + _resolvedPadding!.left + _resolvedPadding!.right;
  });
}