backward method

void backward()

Time travel method. An undo function for states. This method will set the model state one step behind.

Implementation

void backward() {
  if (!identical(_currentActiveModel, _initialMomentumModel)) {
    var latestModel = _momentumModelHistory!.last;
    _nextModel = latestModel;
    _momentumModelHistory!.removeWhere((x) => identical(x, latestModel));
    _momentumModelHistory!.insert(0, latestModel);
    _prevModel = trycatch(
      // ignore: unnecessary_cast
      (() => _momentumModelHistory![_momentumModelHistory!.length - 2]!) as M
          Function(),
    );
    _setMomentum(null, backward: true);
  }
}