getRectsInSelection method

  1. @override
List<Rect> getRectsInSelection(
  1. Selection selection, {
  2. bool shiftWithBaseOffset = false,
})
override

Returns a List of the Rect area within selection in current widget.

The return result must be a List of the Rect under the local coordinate system.

Implementation

@override
List<Rect> getRectsInSelection(
  Selection selection, {
  bool shiftWithBaseOffset = false,
}) {
  if (_renderBox == null) {
    return [];
  }
  final parentBox = context.findRenderObject();
  final imageBox = imageKey.currentContext?.findRenderObject();
  if (parentBox is RenderBox && imageBox is RenderBox) {
    return [
      imageBox.localToGlobal(Offset.zero, ancestor: parentBox) &
          imageBox.size,
    ];
  }
  return [Offset.zero & _renderBox!.size];
}