TrainHoppingAnimation constructor
- 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,
}) {
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/animation.dart',
className: '$TrainHoppingAnimation',
object: this,
);
}
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);
}