updateTree method

  1. @override
void updateTree(
  1. double dt
)
override

This method traverses the component tree and calls update on all its children according to their priority order, relative to the priority of the direct siblings, not the children or the ancestors.

Implementation

@override
void updateTree(double dt) {
  if (!_isRunning) return;

  if (_reversing) {
    _currentValue -= dt * _maxInMilliSeconds;
  } else {
    _currentValue += dt * _maxInMilliSeconds;
  }

  if (_currentValue >= duration.inMilliseconds) {
    if (infinite) {
      _reversing = true;
    } else {
      finish();
    }
  } else if (_currentValue <= 0 && _reversing) {
    _currentValue = 0;
    _reversing = false;
  } else {
    double realValue;
    if (_reversing) {
      double value = (reverseCurve ?? curve)
          .transform(1 - (_currentValue / duration.inMilliseconds));
      realValue = begin + (_displacement * (1 - value));
    } else {
      double value = curve.transform(_currentValue / duration.inMilliseconds);
      realValue = begin + (_displacement * value);
    }

    onChange?.call(realValue);
  }
}