clearReorderPreview method

void clearReorderPreview({
  1. required bool animate,
  2. Duration? duration,
  3. Curve? curve,
})

Ends the make-room preview: animate the shifted rows back (animate true, pointer left every valid slot, or the drag was cancelled) or drop the offsets instantly (animate false, the commit path, where the staged FLIP baseline has already captured the shifted painted positions and the mutation's layout takes over).

Implementation

void clearReorderPreview({
  required bool animate,
  Duration? duration,
  Curve? curve,
}) {
  // BEFORE the hasActive early return: a cleared-then-restarted preview
  // must never memo-skip its first re-install, and the empty-target
  // (own-slot) memo state has no engine entries to make hasActive true.
  _previewMemoValid = false;
  if (!_preview.hasActive) {
    return;
  }
  // Null timing resolves to the style's effective make-room spec; a
  // resolved zero snaps (mirrors [setReorderPreview]'s snap rule).
  final resolvedDuration =
      duration ?? _animationStyle.effectiveMakeRoom.duration;
  if (!animate ||
      _animationStyle.effectiveMakeRoom.duration == Duration.zero ||
      resolvedDuration == Duration.zero) {
    _preview.snapClearAll();
  } else {
    _preview.releaseAll(
      duration: resolvedDuration,
      curve: curve ?? _animationStyle.effectiveMakeRoom.curve,
    );
  }
}