updateFloatingCursor method
Updates the floating cursor position and state.
See also:
- FloatingCursorDragState, which explains the floating cursor feature in detail.
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;
}
}