setPlaceholderDimensions method

void setPlaceholderDimensions(
  1. List<PlaceholderDimensions>? value
)

Sets the dimensions of each placeholder in text.

The number of PlaceholderDimensions provided should be the same as the number of PlaceholderSpans in text. Passing in an empty or null value will do nothing.

If layout is attempted without setting the placeholder dimensions, the placeholders will be ignored in the text layout and no valid inlinePlaceholderBoxes will be returned.

Implementation

void setPlaceholderDimensions(List<PlaceholderDimensions>? value) {
  if (value == null || value.isEmpty || listEquals(value, _placeholderDimensions)) {
    return;
  }
  assert(() {
    int placeholderCount = 0;
    text!.visitChildren((InlineSpan span) {
      if (span is PlaceholderSpan) {
        placeholderCount += 1;
      }
      return value.length >= placeholderCount;
    });
    return placeholderCount == value.length;
  }());
  _placeholderDimensions = value;
  markNeedsLayout();
}