morphTo method

void morphTo(
  1. MorphIconData icon, {
  2. SpringPreset? preset,
  3. double? stiffness,
  4. double? damping,
  5. Duration? duration,
})

Springs to icon. Interruptible: called mid-flight it re-plans from the shape currently on screen and carries the spring's velocity across.

duration asks for a settle time instead of a stiffness; see resolveSpring for how it combines with the other knobs. Duration.zero (or negative) means "no animation" and degrades to set, the same way reducedMotion does. It describes a morph started at rest — an interruption arrives carrying the previous flight's momentum and finishes on its own terms.

Implementation

void morphTo(
  MorphIconData icon, {
  SpringPreset? preset,
  double? stiffness,
  double? damping,
  Duration? duration,
}) {
  if (_dead) return;
  // Already there, or already on the way.
  if (identical(icon, _target) && (_rest || _ticker.isActive)) return;
  if (reducedMotion || (duration != null && duration <= Duration.zero)) {
    _setNow(icon);
    return;
  }
  final s = resolveSpring(
    preset: preset,
    stiffness: stiffness,
    damping: damping,
    duration: duration,
  );
  _spring.config(s.k, s.c);
  _retarget(icon);
  _spring.start();
  if (!_ticker.isActive) {
    _last = null;
    _ticker.start();
  }
}