updateFloatingCursor method

  1. @protected
  2. @override
void updateFloatingCursor(
  1. RawFloatingCursorPoint point
)
override

Updates the floating cursor position and state.

See also:

Implementation

@protected
@override
void updateFloatingCursor(RawFloatingCursorPoint point) {
  if (readOnly) return;

  switch (point.state) {
    case FloatingCursorDragState.Start:
      _floatingCursorStartPosition = getFloatingCursorStartPosition?.call();
      break;
    case FloatingCursorDragState.Update:
      if (point.offset == null ||
          _floatingCursorStartPosition == null ||
          getTextOffsetForFloatingCursorPosition == null) {
        return;
      }
      final targetPosition = _floatingCursorStartPosition! + point.offset!;
      final newOffset = getTextOffsetForFloatingCursorPosition!(
        targetPosition,
      );
      setSelectionSilently(TextSelection.collapsed(offset: newOffset));
      break;
    case FloatingCursorDragState.End:
      _floatingCursorStartPosition = null;
      break;
  }
}