From e23bdac995d2206f42e739fd89d6ef7965e14001 Mon Sep 17 00:00:00 2001 From: Kima Date: Wed, 19 Jun 2024 16:43:56 +0200 Subject: [PATCH] fixed sort issue --- refilc_mobile_ui/lib/pages/grades/grades_page.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/refilc_mobile_ui/lib/pages/grades/grades_page.dart b/refilc_mobile_ui/lib/pages/grades/grades_page.dart index 4e6163d..fcc7dc7 100644 --- a/refilc_mobile_ui/lib/pages/grades/grades_page.dart +++ b/refilc_mobile_ui/lib/pages/grades/grades_page.dart @@ -162,7 +162,12 @@ class GradesPageState extends State { bool hasHomework = homeworkCount > 0; List allExams = examProvider.exams; - allExams.sort((a, b) => a.date.compareTo(b.date)); + try { + allExams.sort((a, b) => a.date.compareTo(b.date)); + } catch (e) { + print('failed to sort exams, reason: flutter'); + allExams = []; + } Exam? nearestExam = allExams.firstWhereOrNull((e) => e.subject.id == subject.id && e.writeDate.isAfter(DateTime.now()));