start method
Implementation
Future<void> start(WorkoutPlan plan, {bool resumeIfPossible = true}) async {
final switchingPlan = _state != null && _state!.planId != plan.id;
_plan = plan;
await _storage.savePlan(json: plan.toJson());
if (_state == null || !resumeIfPossible || switchingPlan) {
final now = DateTime.now();
_state = WorkoutRunnerState(
planId: plan.id,
exerciseIndex: 0,
activeExerciseIndex: null,
setIndex: 0,
isActive: true,
startedAt: now,
updatedAt: now,
performed: [],
exerciseStartedAt: now,
setStartedAt: now,
);
_activeExerciseIndex = null;
elapsed = Duration.zero;
}
_setTicker?.cancel();
_setTicker = null;
_setStartedAt = null;
_setElapsed = Duration.zero;
_activeSetExerciseIndex = null;
_activeSetIndex = null;
_restTicker?.cancel();
_restTicker = null;
_restRemaining = Duration.zero;
_startGlobalTimer();
_persist();
notifyListeners();
}