rectsForSelection method

List<Rect> rectsForSelection(
  1. TextSelection selection
)

Returns the list of Rects for the selection.

Implementation

List<Rect> rectsForSelection(TextSelection selection) {
  if (rp == null) return [];
  final textBoxes = rp!.getBoxesForSelection(selection);
  if (textBoxes.isNotEmpty) {
    return textBoxes
        .map((r) => r.toRect().translate(rect.left, rect.top))
        .toList();
  }
  return [];
}