addEffect method

  1. @override
Animate addEffect(
  1. Effect effect
)
override

Adds an effect. This is mostly used by Effect extension methods to append effects to an Animate instance.

Implementation

@override
Animate addEffect(Effect effect) {
  EffectEntry? prior = _lastEntry;

  Duration delay = (effect is ThenEffect)
      ? (effect.delay ?? Duration.zero) +
          (prior?.delay ?? Duration.zero) +
          (prior?.duration ?? Duration.zero)
      : effect.delay ?? prior?.delay ?? Duration.zero;

  EffectEntry entry = EffectEntry(
    effect: effect,
    delay: delay,
    duration: effect.duration ?? prior?.duration ?? Animate.defaultDuration,
    curve: effect.curve ?? prior?.curve ?? Animate.defaultCurve,
    owner: this,
  );

  _entries.add(entry);
  _lastEntry = entry;
  if (entry.end > _duration) _duration = entry.end;
  return this;
}