onDragSelectionUpdate method

  1. @protected
void onDragSelectionUpdate(
  1. DragStartDetails startDetails,
  2. DragUpdateDetails updateDetails
)

Handler for TextSelectionGestureDetector.onDragSelectionUpdate.

By default, it updates the selection location specified in the provided details objects.

See also:

Implementation

@protected
void onDragSelectionUpdate(
    DragStartDetails startDetails, DragUpdateDetails updateDetails) {
  if (!delegate.selectionEnabled) return;

  // Adjust the drag start offset for possible viewport offset changes.
  final Offset startOffset = renderEditable.maxLines == 1
      ? Offset(renderEditable.offset.pixels - _dragStartViewportOffset, 0.0)
      : Offset(0.0, renderEditable.offset.pixels - _dragStartViewportOffset);

  renderEditable.selectPositionAt(
    from: startDetails.globalPosition - startOffset,
    to: updateDetails.globalPosition,
    cause: SelectionChangedCause.drag,
  );
}