TrainHoppingAnimation constructor Null safety
- Animation<
double> _currentTrain, - Animation<
double> ? _nextTrain, - {VoidCallback? onSwitchedTrain}
Creates a train-hopping animation.
The current train argument must not be null but the next train argument can be null. If the next train is null, then this object will just proxy the first animation and never hop.
Implementation
TrainHoppingAnimation(
Animation<double> this._currentTrain,
this._nextTrain, {
this.onSwitchedTrain,
}) : assert(_currentTrain != null) {
if (_nextTrain != null) {
if (_currentTrain!.value == _nextTrain!.value) {
_currentTrain = _nextTrain;
_nextTrain = null;
} else if (_currentTrain!.value > _nextTrain!.value) {
_mode = _TrainHoppingMode.maximize;
} else {
assert(_currentTrain!.value < _nextTrain!.value);
_mode = _TrainHoppingMode.minimize;
}
}
_currentTrain!.addStatusListener(_statusChangeHandler);
_currentTrain!.addListener(_valueChangeHandler);
_nextTrain?.addListener(_valueChangeHandler);
assert(_mode != null || _nextTrain == null);
}