ExerciseRecord.fromJson constructor

ExerciseRecord.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory ExerciseRecord.fromJson(Map<String, dynamic> json) {
  final best = json['b'];
  final streak = json['s'];
  final lastAt = json['t'];
  return ExerciseRecord(
    passed: json['p'] == true,
    streak: streak is num ? streak.round().clamp(0, 1000) : 0,
    bestPercent: best is num ? best.round().clamp(0, 100) : 0,
    lastAt: lastAt is num ? lastAt.round() : 0,
  );
}