Skip to content

Commit

Permalink
Fix timetable loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Dec 26, 2023
1 parent af367ed commit cecdca8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ TimeTableData processTimeTable(TimeTableData tt) {
}
}

classes.sort((a, b) =>
int.parse(a.startPeriod!.id).compareTo(int.parse(b.startPeriod!.id)));
classes.sort((a, b) {
int? sp = int.tryParse(a.startPeriod!.id);
int? ep = int.tryParse(b.endPeriod!.id);
if (sp == null || ep == null) return 0;
return sp.compareTo(ep);
});
periods.sort((a, b) => a.startTime.compareTo(b.startTime));

List<TimeTableClass> newClasses = [];
Expand Down Expand Up @@ -208,8 +212,12 @@ TimeTableData processTimeTable(TimeTableData tt) {
}

classes.addAll(newClasses);
classes.sort((a, b) =>
int.parse(a.startPeriod!.id).compareTo(int.parse(b.startPeriod!.id)));
classes.sort((a, b) {
int? sp = int.tryParse(a.startPeriod!.id);
int? ep = int.tryParse(b.endPeriod!.id);
if (sp == null || ep == null) return 0;
return sp.compareTo(ep);
});

return TimeTableData(tt.date, classes, periods);
}
Expand Down

0 comments on commit cecdca8

Please sign in to comment.