positionInlineChildren method

  1. @protected
void positionInlineChildren(
  1. List<TextBox> boxes
)

Positions each inline child according to the coordinates provided in the boxes list.

The boxes list must be in logical order, which is the order each child is encountered when the user reads the text. Usually the length of the list equals childCount, but it can be less than that, when some children are omitted due to ellipsing. It never exceeds childCount.

See also:

Implementation

@protected
void positionInlineChildren(List<ui.TextBox> boxes) {
  RenderBox? child = firstChild;
  for (final box in boxes) {
    if (child == null) {
      assert(() {
        throw FlutterError.fromParts(<DiagnosticsNode>[
          ErrorSummary('Invalid number of boxes provided to positionInlineChildren.'),
          ErrorDescription(
            'The number of boxes (${boxes.length}) exceeds the number of child render objects ($childCount). '
            'Each box corresponds to a child, but there are not enough children to position all boxes.',
          ),
          ErrorHint(
            'This error typically occurs when a custom InlineSpan implementation returns a list of boxes '
            'that is longer than the number of inline children. Ensure that the number of boxes returned '
            'by `computeLineMetrics` or similar methods does not exceed the number of children.',
          ),
          DiagnosticsProperty<RenderObject>(
            'The RenderParagraph receiving the boxes',
            this,
            style: DiagnosticsTreeStyle.errorProperty,
          ),
        ]);
      }());
      return;
    }
    final textParentData = child.parentData! as TextParentData;
    textParentData._offset = Offset(box.left, box.top);
    child = childAfter(child);
  }
  while (child != null) {
    final textParentData = child.parentData! as TextParentData;
    textParentData._offset = null;
    child = childAfter(child);
  }
}