stateUpdate method

void stateUpdate(
  1. RaceFullState newFullState,
  2. double standstillDurationBeforeStart,
  3. dynamic callback(
    1. double
    )
)

Implementation

void stateUpdate(RaceFullState newFullState, double standstillDurationBeforeStart, Function(double) callback) {
  Iterable<bool> currentLaneAutostartPending = newFullState.laneStates.map((laneState) =>
    laneState.extraState.trainingClassicRaceExtraState.autostartPending);

  _timer.cancel();
  _progress = 0.0;
  callback(_progress);

  if (currentLaneAutostartPending.any((element) => element) && !listEquals(oldLaneAutostartPending.toList(), currentLaneAutostartPending.toList())) {
    _timer.start((elapsed) {
      _progress = elapsed.inMilliseconds / standstillDurationBeforeStart;
      callback(_progress);
    }, 10);
  }
  oldLaneAutostartPending = currentLaneAutostartPending;
}