import 'package:json_annotation/json_annotation.dart'; import 'package:wger/helpers/json.dart'; import 'package:wger/models/exercises/exercise.dart'; part 'setting.g.dart'; @JsonSerializable() class Setting { @JsonKey(required: true) int id; @JsonKey(required: true, name: 'set') int setId; @JsonKey(required: false) Exercise exerciseObj; @JsonKey(required: true, name: 'exercise') int exerciseId; @JsonKey(required: true, name: 'repetition_unit') int repetitionUnit; @JsonKey(required: true) int reps; @JsonKey(required: true, fromJson: toNum, toJson: toString) num weight; @JsonKey(required: true, name: 'weight_unit') int weightUnit; @JsonKey(required: true, defaultValue: '') String comment = ''; @JsonKey(required: false, defaultValue: '') String rir = ''; // Generated by Server @JsonKey(required: false) String repsText; Setting({ this.id, this.setId, this.exerciseObj, this.repetitionUnit, this.reps, this.weight, this.weightUnit, this.comment, this.rir, this.repsText, }) { if (exerciseObj != null) { this.exerciseId = exerciseObj.id; } } // Boilerplate factory Setting.fromJson(Map json) => _$SettingFromJson(json); Map toJson() => _$SettingToJson(this); }