tick method

void tick(
  1. Duration delta
)

Advances the animation by the given time delta.

Call this method regularly (e.g., from a ticker) to progress animations. If the current animation completes, the next queued animation starts.

Parameters

  • delta - The time elapsed since the last tick.

Side Effects

Updates value and notifies listeners as the animation progresses.

Example

// In a ticker callback
void _tick(Duration elapsed) {
  final delta = elapsed - _lastElapsed;
  controller.tick(delta);
  _lastElapsed = elapsed;
}

Implementation

void tick(Duration delta) {
  if (_requests.isNotEmpty) {
    final request = _requests.removeAt(0);
    _runner = AnimationRunner(
        _value, request.target, request.duration, request.curve);
  }
  final runner = _runner;
  if (runner != null) {
    runner._progress += delta.inMilliseconds / runner.duration.inMilliseconds;
    _value = runner.from +
        (runner.to - runner.from) *
            runner.curve.transform(runner._progress.clamp(0, 1));
    if (runner._progress >= 1.0) {
      _runner = null;
    }
    notifyListeners();
  }
}