setFloatingCursor method Null safety

void setFloatingCursor(
  1. FloatingCursorDragState state,
  2. Offset boundedOffset,
  3. TextPosition lastTextPosition,
  4. {double? resetLerpValue}
)

Sets the screen position of the floating cursor and the text position closest to the cursor.

Implementation

void setFloatingCursor(FloatingCursorDragState state, Offset boundedOffset, TextPosition lastTextPosition, { double? resetLerpValue }) {
  assert(state != null);
  assert(boundedOffset != null);
  assert(lastTextPosition != null);
  if (state == FloatingCursorDragState.Start) {
    _relativeOrigin = Offset.zero;
    _previousOffset = null;
    _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(_kFloatingCaretSizeIncrease, EdgeInsets.zero, animationValue)!
      : _kFloatingCaretSizeIncrease;
    _caretPainter.floatingCursorRect = sizeAdjustment.inflateRect(_caretPrototype).shift(boundedOffset);
  } else {
    _caretPainter.floatingCursorRect = null;
  }
  _caretPainter.showRegularCaret = _resetFloatingCursorAnimationValue == null;
}