computeMinIntrinsicHeight method

  1. @override
double computeMinIntrinsicHeight (double width)
override

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

Override in subclasses that implement performLayout. Should return the minimum height that this box could be without failing to correctly paint its contents within itself, without clipping.

If the layout algorithm is independent of the context (e.g. it always tries to be a particular size), or if the layout algorithm is height-in-width-out, or if the layout algorithm uses both the incoming height and width constraints (e.g. it always sizes itself to BoxConstraints.biggest), then the width argument should be ignored.

If the layout algorithm is strictly width-in-height-out, or is width-in-height-out when the height is unconstrained, then the width argument is the width to use.

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

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.

See also examples in the definition of computeMinIntrinsicWidth.

Implementation

@override
double computeMinIntrinsicHeight(double width) {
  // winner of the 2016 world's most expensive intrinsic dimension function award
  // honorable mention, most likely to improve if taught about memoization award
  assert(_children.length == rows * columns);
  final List<double> widths = _computeColumnWidths(BoxConstraints.tightForFinite(width: width));
  double rowTop = 0.0;
  for (int y = 0; y < rows; y += 1) {
    double rowHeight = 0.0;
    for (int x = 0; x < columns; x += 1) {
      final int xy = x + y * columns;
      final RenderBox child = _children[xy];
      if (child != null)
        rowHeight = math.max(rowHeight, child.getMaxIntrinsicHeight(widths[x]));
    }
    rowTop += rowHeight;
  }
  return rowTop;
}