resetMachine method

void resetMachine()

Starts the sequence processing. If called again, it restarts from the beginning.

When using StandardAppPlugin, upon restart, navigation will be directed to the first page in StandardMaterialApp.pages or StandardCupertinoApp.pages. To customize this behavior, implement a Plugin that overrides StartupNavigatorMixin.startupOnReset.

Implementation

void resetMachine() {
  final tIsFirstRun = !(_machine != null || complete);
  if (_waitSplashScreenTimer?.isActive == true) {
    _waitSplashScreenTimer?.cancel();
  }

  _waitSplashScreenTimer = Timer(_waitSplashScreenDuration, () {
    getApp().removeNativeSplashScreen().whenComplete(() {
      _splashFinished = true;
      _splashScreenCompleter?.complete();
      _splashScreenCompleter = null;
      _waitSplashScreenTimer = null;
    });
  });

  final tPreMachine = _machine;
  _machine?.removeListener(_onUpdate);
  _error = null;
  _splashFinished = false;
  _startupCompleted = false;
  StartupNavigatorObserver._routeHashStateMap.clear();
  _machine = LogicStateMachine(_createLogicStateFactories())
    ..addListener(_onUpdate);

  if (!tIsFirstRun) {
    if (tPreMachine?.complete == false) {
      tPreMachine?.current.completeError(ResetStartupSequence());
    }
    _startupNavigator?.startupOnReset();
  }
}