import 'ExercisePrescription.dart'; class SessionTemplate { String? id; String programId; /// 0-based day within the training week. int dayIndex; String name; /// True when this session loads the lower body hard enough to require the /// program recovery gap before the next one. bool highIntensityLowerBody; List prescriptions; SessionTemplate({ this.id, this.programId = "", this.dayIndex = 0, this.name = "", this.highIntensityLowerBody = false, List? prescriptions, }) : prescriptions = prescriptions ?? []; factory SessionTemplate.fromJson(Map json) { return SessionTemplate( id: json['id'], programId: json['programId'] ?? "", dayIndex: json['dayIndex'] ?? 0, name: json['name'] ?? "", highIntensityLowerBody: json['highIntensityLowerBody'] ?? false, prescriptions: json['prescriptions'] == null ? [] : (json['prescriptions'] as List) .map((item) => ExercisePrescription.fromJson(item)) .toList(), ); } Map toJson() { final Map data = {}; data['id'] = id; data['programId'] = programId; data['dayIndex'] = dayIndex; data['name'] = name; data['highIntensityLowerBody'] = highIntensityLowerBody; data['prescriptions'] = prescriptions.map((item) => item.toJson()).toList(); return data; } }