forward method
void
forward()
Time travel method.
A redo
function for states.
If backward()
was called before, this method will
set the model state one step ahead.
Implementation
void forward() {
var latestNotNull = _latestMomentumModel != null;
var currentNotLatest = !identical(
_currentActiveModel,
_latestMomentumModel,
);
if (latestNotNull && currentNotLatest) {
var firstModel = _momentumModelHistory!.first;
_momentumModelHistory!.removeWhere((x) => identical(x, firstModel));
_momentumModelHistory!.add(firstModel);
_prevModel = trycatch(
// ignore: unnecessary_cast
(() => _momentumModelHistory![_momentumModelHistory!.length - 2]!) as M
Function(),
);
// ignore: unnecessary_cast
_nextModel = trycatch((() => _momentumModelHistory![0]!) as M Function());
if (identical(_nextModel, _initialMomentumModel)) {
_nextModel = null;
}
_setMomentum(null, forward: true);
}
}