layoutInlineChildren method

  1. @override
List<PlaceholderDimensions> layoutInlineChildren(
  1. double maxWidth,
  2. ChildLayouter layoutChild,
  3. ChildBaselineGetter getChildBaseline
)
override

Computes the layout for every inline child using the maxWidth constraint.

Returns a list of PlaceholderDimensions, representing the layout results for each child managed by the ContainerRenderObjectMixin mixin.

The getChildBaseline parameter and the layoutChild parameter must be consistent: if layoutChild computes the size of the child without modifying the actual layout of that child, then getChildBaseline must also be "dry", and vice versa.

Since this method does not impose a maximum height constraint on the inline children, some children may become taller than this RenderBox.

See also:

Implementation

@override
List<PlaceholderDimensions> layoutInlineChildren(
  double maxWidth,
  ChildLayouter layoutChild,
  ChildBaselineGetter getChildBaseline,
) {
  final dimensions = super.layoutInlineChildren(
    maxWidth,
    layoutChild,
    getChildBaseline,
  );
  // Dry passes only measure. Permuting placeholders within a line never
  // changes the line's total width, so the dry size is the same either way,
  // and the cached order must not be clobbered before `performLayout` reads
  // it back in `positionInlineChildren`.
  if (!identical(layoutChild, ChildLayoutHelper.layoutChild)) {
    return dimensions;
  }
  _inverse = null;
  if (!_bidiEnabled) {
    return dimensions;
  }
  if (dimensions.length < 2) {
    return dimensions;
  }
  final order = _computeVisualOrder(dimensions, maxWidth);
  if (order == null) {
    return dimensions;
  }
  final inverse = List<int>.filled(order.length, 0);
  for (var boxIndex = 0; boxIndex < order.length; boxIndex++) {
    inverse[order[boxIndex]] = boxIndex;
  }
  _inverse = inverse;
  return <PlaceholderDimensions>[for (final i in order) dimensions[i]];
}