setPlaceholderDimensions method Null safety
- 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 true;
});
return placeholderCount;
}() == value.length);
_placeholderDimensions = value;
markNeedsLayout();
}