getMaxIntrinsicHeight method

  1. @mustCallSuper
double getMaxIntrinsicHeight (double width)
@mustCallSuper

Returns the smallest height beyond which increasing the height never decreases the preferred width. The preferred width is the value that would be returned by getMinIntrinsicWidth for that height.

The width argument may give a specific width to assume. The given width can be infinite, meaning that the intrinsic height in an unconstrained environment is being requested. The given width should never be negative or null.

This function should only be called on one's children. Calling this function couples the child with the parent so that when the child's layout changes, the parent is notified (via markNeedsLayout).

Calling this function is expensive and as it can result in O(N^2) behavior.

Do not override this method. Instead, implement computeMaxIntrinsicHeight.

Implementation

@mustCallSuper
double getMaxIntrinsicHeight(double width) {
  assert(() {
    if (width == null) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('The width argument to getMaxIntrinsicHeight was null.'),
        ErrorDescription('The argument to getMaxIntrinsicHeight must not be negative or null.'),
        ErrorHint('If you do not have a specific width in mind, then pass double.infinity instead.')
      ]);
    }
    if (width < 0.0) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('The width argument to getMaxIntrinsicHeight was negative.'),
        ErrorDescription('The argument to getMaxIntrinsicHeight must not be negative or null.'),
        ErrorHint(
          'If you perform computations on another width before passing it to '
          'getMaxIntrinsicHeight, consider using math.max() or double.clamp() '
          'to force the value into the valid range.'
        )
      ]);
    }
    return true;
  }());
  return _computeIntrinsicDimension(_IntrinsicDimension.maxHeight, width, computeMaxIntrinsicHeight);
}