mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-07-04 11:43:09 +02:00
- Add sqflite_common_ffi + very_good_analysis; tighten analysis_options - Add BackupService for JSON export/import of exercise state - Add full test coverage: models, screens, services, widgets - Add scripts/check_flutter_coverage.sh to enforce 100% line coverage - Add docstrings to ExerciseState fields and storage service - Minor fixes across screens, widgets, and sync/HTTP services Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VuiPt6GPWkxpLbJFrnfy8U
47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
/// Result of a single set during a workout session.
|
|
library;
|
|
|
|
/// Immutable result of one set, recording target vs actual reps.
|
|
class SetResult {
|
|
/// Creates a set result.
|
|
const SetResult({
|
|
required this.targetReps,
|
|
required this.doneReps,
|
|
required this.weight,
|
|
});
|
|
|
|
/// Deserializes a set result from a JSON map.
|
|
factory SetResult.fromJson(Map<String, dynamic> json) => SetResult(
|
|
targetReps: json['targetReps'] as int,
|
|
doneReps: json['doneReps'] as int,
|
|
weight: (json['weight'] as num).toDouble(),
|
|
);
|
|
|
|
/// Target number of reps for this set.
|
|
final int targetReps;
|
|
|
|
/// Reps actually completed (may be less than [targetReps] on failure).
|
|
final int doneReps;
|
|
|
|
/// Weight used for this set in kg.
|
|
final double weight;
|
|
|
|
/// True when the user completed every target rep.
|
|
bool get succeeded => doneReps >= targetReps;
|
|
|
|
/// Returns a copy with [doneReps] replaced.
|
|
SetResult copyWith({int? doneReps}) => SetResult(
|
|
targetReps: targetReps,
|
|
doneReps: doneReps ?? this.doneReps,
|
|
weight: weight,
|
|
);
|
|
|
|
/// Serializes this set result to a JSON map.
|
|
Map<String, dynamic> toJson() => {
|
|
'targetReps': targetReps,
|
|
'doneReps': doneReps,
|
|
'weight': weight,
|
|
'succeeded': succeeded,
|
|
};
|
|
}
|