selectionEndpoints property

List<TextSelectionPoint> selectionEndpoints

Returns the local coordinates of the endpoints of the current selection.

Implementation

List<TextSelectionPoint> get selectionEndpoints {
  final SelectionPoint? start = _selectionDelegate.value.startSelectionPoint;
  final SelectionPoint? end = _selectionDelegate.value.endSelectionPoint;
  late List<TextSelectionPoint> points;
  final Offset startLocalPosition = start?.localPosition ?? end!.localPosition;
  final Offset endLocalPosition = end?.localPosition ?? start!.localPosition;
  if (startLocalPosition.dy > endLocalPosition.dy) {
    points = <TextSelectionPoint>[
      TextSelectionPoint(endLocalPosition, TextDirection.ltr),
      TextSelectionPoint(startLocalPosition, TextDirection.ltr),
    ];
  } else {
    points = <TextSelectionPoint>[
      TextSelectionPoint(startLocalPosition, TextDirection.ltr),
      TextSelectionPoint(endLocalPosition, TextDirection.ltr),
    ];
  }
  return points;
}