getBoxesForSelection method Null safety
- TextSelection selection,
- {BoxHeightStyle boxHeightStyle = ui.BoxHeightStyle.tight,
- BoxWidthStyle boxWidthStyle = ui.BoxWidthStyle.tight}
Returns a list of rects that bound the given selection.
The boxHeightStyle
and boxWidthStyle
arguments may be used to select
the shape of the TextBox
es. These properties default to
ui.BoxHeightStyle.tight and ui.BoxWidthStyle.tight respectively and
must not be null.
A given selection might have more than one rect if the RenderParagraph contains multiple InlineSpans or bidirectional text, because logically contiguous text might not be visually contiguous.
Valid only after layout.
See also:
- TextPainter.getBoxesForSelection, the method in TextPainter to get the equivalent boxes.
Implementation
List<ui.TextBox> getBoxesForSelection(
TextSelection selection, {
ui.BoxHeightStyle boxHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle boxWidthStyle = ui.BoxWidthStyle.tight,
}) {
assert(!debugNeedsLayout);
assert(boxHeightStyle != null);
assert(boxWidthStyle != null);
_layoutTextWithConstraints(constraints);
return _textPainter.getBoxesForSelection(
selection,
boxHeightStyle: boxHeightStyle,
boxWidthStyle: boxWidthStyle,
);
}