advanceTime method

  1. @override
bool advanceTime(
  1. num time
)
override

This method is called by the Juggler with the time past since the last call.

Returns true as long as this Animatable is not completed; false if it is completed.

Implementation

@override
bool advanceTime(num time) {
  if (_currentTime < _totalTime || _started == false) {
    _currentTime = _currentTime + time;

    if (_currentTime > _totalTime) _currentTime = _totalTime;

    if (_currentTime >= 0.0) {
      if (_started == false) {
        _started = true;
        if (_onStart != null) _onStart!();
      }

      final num ratio = _currentTime / _totalTime;
      final transition = _transition(ratio);

      _currentValue = _startValue + transition * (_targetValue - _startValue);

      if (_onUpdate != null) {
        _onUpdate!(roundToInt ? _currentValue.round() : _currentValue);
      }
      if (_onComplete != null && _currentTime == _totalTime) {
        _onComplete!();
      }
    }
  }

  return _currentTime < _totalTime;
}