getBoxesForSelection method

List<TextBox> getBoxesForSelection(
  1. TextSelection selection
)

Returns a list of rects that bound the given selection, and the text direction. The text direction is used by the engine to calculate the closest position to a given point.

See TextPainter.getBoxesForSelection for more details.

Implementation

List<TextBox> getBoxesForSelection(TextSelection selection) {
  _computeTextMetricsIfNeeded();
  return _textPainter.getBoxesForSelection(selection)
                     .map((TextBox textBox) => TextBox.fromLTRBD(
                        textBox.left + _paintOffset.dx,
                        textBox.top + _paintOffset.dy,
                        textBox.right + _paintOffset.dx,
                        textBox.bottom + _paintOffset.dy,
                        textBox.direction
                      )).toList();
}