Make order of sets a required attribute

Closes #109
This commit is contained in:
Roland Geider
2021-10-28 11:43:32 +02:00
parent 27eef231f1
commit a4e381e4c8
3 changed files with 4 additions and 4 deletions

View File

@@ -36,7 +36,7 @@ class Set {
late int day;
@JsonKey(required: true)
int? order;
late int order;
@JsonKey(required: true, defaultValue: '')
late String comment;
@@ -58,7 +58,7 @@ class Set {
Set({
required this.day,
required this.sets,
this.order,
required this.order,
});
Set.empty();

View File

@@ -11,7 +11,7 @@ Set _$SetFromJson(Map<String, dynamic> json) {
return Set(
day: json['exerciseday'] as int,
sets: json['sets'] as int,
order: json['order'] as int?,
order: json['order'] as int,
)
..id = json['id'] as int?
..comment = json['comment'] as String? ?? '';

View File

@@ -101,7 +101,7 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
void initState() {
super.initState();
_sets = widget._day.sets;
_sets.sort((a, b) => a.order!.compareTo(b.order!));
_sets.sort((a, b) => a.order.compareTo(b.order));
}
void _toggleExpanded() {