setFloatingCursor method
- FloatingCursorDragState state,
- Offset boundedOffset,
- TextPosition lastTextPosition, {
- double? resetLerpValue,
Sets the screen position of the floating cursor and the text position closest to the cursor.
See also:
- FloatingCursorDragState, which explains the floating cursor feature in detail.
Implementation
void setFloatingCursor(FloatingCursorDragState state, Offset boundedOffset, TextPosition lastTextPosition, { double? resetLerpValue }) {
if (state == FloatingCursorDragState.End) {
_relativeOrigin = Offset.zero;
_previousOffset = null;
_shouldResetOrigin = true;
_resetOriginOnBottom = false;
_resetOriginOnTop = false;
_resetOriginOnRight = false;
_resetOriginOnBottom = false;
}
_floatingCursorOn = state != FloatingCursorDragState.End;
_resetFloatingCursorAnimationValue = resetLerpValue;
if (_floatingCursorOn) {
_floatingCursorTextPosition = lastTextPosition;
final double? animationValue = _resetFloatingCursorAnimationValue;
final EdgeInsets sizeAdjustment = animationValue != null
? EdgeInsets.lerp(_kFloatingCursorSizeIncrease, EdgeInsets.zero, animationValue)!
: _kFloatingCursorSizeIncrease;
_caretPainter.floatingCursorRect = sizeAdjustment.inflateRect(_caretPrototype).shift(boundedOffset);
} else {
_caretPainter.floatingCursorRect = null;
}
_caretPainter.showRegularCaret = _resetFloatingCursorAnimationValue == null;
}