startSet method
Implementation
bool startSet(int exerciseIndex, int setIndex) {
if (_plan == null || _state == null) return false;
if (!canActivateSet(exerciseIndex)) return false;
if (_activeSetExerciseIndex != null || _activeSetIndex != null) {
return false;
}
if (exerciseIndex < 0 || exerciseIndex >= exercises.length) return false;
if (setIndex < 0 || setIndex >= exercises[exerciseIndex].sets.length) {
return false;
}
if (getPerformedSet(exerciseIndex, setIndex) != null) return false;
_restTicker?.cancel();
_restTicker = null;
_restRemaining = Duration.zero;
_activeSetExerciseIndex = exerciseIndex;
_activeSetIndex = setIndex;
_setStartedAt = DateTime.now();
_setElapsed = Duration.zero;
_setTicker?.cancel();
_setTicker = Timer.periodic(const Duration(seconds: 1), (_) {
if (_setStartedAt != null) {
_setElapsed = DateTime.now().difference(_setStartedAt!);
notifyListeners();
}
});
notifyListeners();
return true;
}