Spaces:
Running
Running
| import 'package:isar/isar.dart'; | |
| import 'workout_exercise.dart'; | |
| part 'set_entry.g.dart'; | |
| class SetEntry { | |
| Id id = Isar.autoIncrement; | |
| double? weight; | |
| int? reps; | |
| double? rpe; // Rate of Perceived Exertion 6-10 | |
| String? tempo; // e.g., "3-1-2-0" | |
| int? restSeconds; | |
| final workoutExercise = IsarLink<WorkoutExercise>(); | |
| SetEntry({ | |
| this.weight, | |
| this.reps, | |
| this.rpe, | |
| this.tempo, | |
| this.restSeconds, | |
| }); | |
| double? get volume => (weight != null && reps != null) ? weight! * reps! : null; | |
| Map<String, dynamic> toJson() { | |
| return { | |
| 'id': id, | |
| 'weight': weight, | |
| 'reps': reps, | |
| 'rpe': rpe, | |
| 'tempo': tempo, | |
| 'restSeconds': restSeconds, | |
| }; | |
| } | |
| factory SetEntry.fromJson(Map<String, dynamic> json) { | |
| return SetEntry( | |
| weight: json['weight'] != null ? (json['weight'] as num).toDouble() : null, | |
| reps: json['reps'] as int?, | |
| rpe: json['rpe'] != null ? (json['rpe'] as num).toDouble() : null, | |
| tempo: json['tempo'] as String?, | |
| restSeconds: json['restSeconds'] as int?, | |
| )..id = json['id'] as int; | |
| } | |
| } |