getBoxesForSelection method Null safety

List<TextBox> getBoxesForSelection(
  1. TextSelection selection,
  2. {BoxHeightStyle boxHeightStyle = ui.BoxHeightStyle.tight,
  3. 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 TextBoxes. 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:

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,
  );
}