mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-19 07:50:52 +01:00
73 lines
1.6 KiB
Dart
73 lines
1.6 KiB
Dart
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')
|
|
late int setId;
|
|
|
|
@JsonKey(ignore: true)
|
|
late Exercise exerciseObj;
|
|
|
|
@JsonKey(required: true, name: 'exercise')
|
|
late int exerciseId;
|
|
|
|
@JsonKey(required: true, name: 'repetition_unit')
|
|
late int repetitionUnitId;
|
|
|
|
@JsonKey(ignore: true)
|
|
late int repetitionUnitObj;
|
|
|
|
@JsonKey(required: true)
|
|
late int reps;
|
|
|
|
@JsonKey(required: true, fromJson: toNum, toJson: toString)
|
|
late num weight;
|
|
|
|
@JsonKey(required: true, name: 'weight_unit')
|
|
late int weightUnitId;
|
|
|
|
@JsonKey(ignore: true)
|
|
late int weightUnitObj;
|
|
|
|
@JsonKey(required: true, defaultValue: '')
|
|
late String comment = '';
|
|
|
|
@JsonKey(required: false, defaultValue: '')
|
|
late String rir = '';
|
|
|
|
// Generated by Server
|
|
@JsonKey(required: false)
|
|
late String repsText;
|
|
|
|
Setting();
|
|
|
|
Setting.withData({
|
|
this.id,
|
|
required this.setId,
|
|
Exercise? exerciseObj,
|
|
required this.repetitionUnitId,
|
|
required this.reps,
|
|
required this.weight,
|
|
required this.weightUnitId,
|
|
required this.comment,
|
|
this.rir = '',
|
|
required this.repsText,
|
|
}) {
|
|
if (exerciseObj != null) {
|
|
this.exerciseId = exerciseObj.id;
|
|
this.exerciseObj = exerciseObj;
|
|
}
|
|
}
|
|
|
|
// Boilerplate
|
|
factory Setting.fromJson(Map<String, dynamic> json) => _$SettingFromJson(json);
|
|
Map<String, dynamic> toJson() => _$SettingToJson(this);
|
|
}
|