SingleGoalWorkout constructor

SingleGoalWorkout({
  1. required WorkoutActivityType activityType,
  2. required WorkoutGoal goal,
  3. WorkoutLocationType? location,
  4. WorkoutSwimmingLocationType? swimmingLocation,
})

Creates a new single goal workout

Implementation

SingleGoalWorkout({
  required this.activityType,
  required this.goal,
  this.location,
  this.swimmingLocation,
}) : super(workoutType: WorkoutType.singleGoalWorkout) {
  if (activityType == WorkoutActivityType.swimming) {
    if (swimmingLocation == null || location != null) {
      throw ArgumentError(
        'Swimming workouts require swimmingLocation and must not have location set',
      );
    }
  } else {
    if (location == null || swimmingLocation != null) {
      throw ArgumentError(
        'Non-swimming workouts require location and must not have swimmingLocation set',
      );
    }
  }
}