restoreSnapshotAnimated method

Future<void> restoreSnapshotAnimated()

Like restoreSnapshot but fades out the strokes added during the current session before clearing them, so canceling a draw session is a smooth reverse instead of an instant disappear. Returns a Future that completes when the fade + snap finishes — DrawScreen._cancel fires this unawaited and then pops, so the fade overlaps with the screen pop transition.

In-place eraser strokes don't visually un-erase (BlendMode.clear doesn't honour alpha), they just fade in alpha. The final snap at progress=0 restores the under-erased pixels in one frame — acceptable for the edge case.

Implementation

Future<void> restoreSnapshotAnimated() async {
  final s = _snapshot;
  if (s == null) return;
  await _fadeAnimator.animate(target: 0.0);
  _fadeNewStrokes = 1.0;
  strokes
    ..clear()
    ..addAll(s.strokes);
  _snapshotStrokeCount = strokes.length;
  currentBrush = s.currentBrush;
  brushColors
    ..clear()
    ..addAll(s.brushColors);
  _normalizedThickness
    ..clear()
    ..addAll(s.normalizedThickness);
  currentPoints.clear();
  _resetVelocityTracking();
  notifyListeners();
}