diff --git a/lib/src/model/coursetable/course.dart b/lib/src/model/coursetable/course.dart index 1d88c242..848779c0 100644 --- a/lib/src/model/coursetable/course.dart +++ b/lib/src/model/coursetable/course.dart @@ -7,20 +7,20 @@ part 'course.g.dart'; @JsonSerializable() class Course { - late int id; - String name; - late double stage; - late double credit; - late int periodCount; - String category; - late List teachers; - late List classNames; - late List coursePeriods; - late List classrooms; - String applyStatus; - String language; - String syllabusLink; - String note; + late final int id; + final String name; + late final double stage; + late final double credit; + late final int periodCount; + final String category; + late final List teachers; + late final List classNames; + late final List coursePeriods; + late final List classrooms; + final String applyStatus; + final String language; + final String syllabusLink; + final String note; Course( {required this.id, @@ -55,19 +55,13 @@ class Course { required this.note, }) { id = JsonInit.intInit(idString); - name = JsonInit.stringInit(name).trim(); stage = JsonInit.doubleInit(stageString); credit = JsonInit.doubleInit(creditString); periodCount = JsonInit.intInit(periodCountString); - category = JsonInit.stringInit(category).trim(); teachers = teacherString.split(RegExp(r"\n")).map((element) => element.trim()).toList(); coursePeriods = _convertPeriodSlotsToCoursePeriods(periodSlots); classrooms = classroomString.split(RegExp(r"\n")).map((element) => element.trim()).toList(); classNames = classNameString.split(RegExp(r"\n")).map((element) => element.trim()).toList(); - applyStatus = JsonInit.stringInit(applyStatus).trim(); - language = JsonInit.stringInit(language).trim(); - syllabusLink = JsonInit.stringInit(syllabusLink).trim(); - note = JsonInit.stringInit(note).trim(); } bool isEmpty() => id == 0; diff --git a/lib/src/model/coursetable/course_period.dart b/lib/src/model/coursetable/course_period.dart index 89dd8d1f..198fd374 100644 --- a/lib/src/model/coursetable/course_period.dart +++ b/lib/src/model/coursetable/course_period.dart @@ -4,13 +4,10 @@ part 'course_period.g.dart'; @JsonSerializable() class CoursePeriod { - int weekday; - String period; + final int weekday; + final String period; - CoursePeriod({required this.weekday, required this.period}) { - weekday = weekday; - period = period; - } + CoursePeriod({required this.weekday, required this.period}); factory CoursePeriod.fromJson(Map json) => _$CoursePeriodFromJson(json); diff --git a/lib/src/model/coursetable/course_table.dart b/lib/src/model/coursetable/course_table.dart index 54168867..797e8df8 100644 --- a/lib/src/model/coursetable/course_table.dart +++ b/lib/src/model/coursetable/course_table.dart @@ -7,18 +7,14 @@ part 'course_table.g.dart'; @JsonSerializable() class CourseTable { - int year; - int semester; - List courses; - User user; + final int year; + final int semester; + final List courses; + final User user; late final Set weekdays = {}; late final Set periods = {}; CourseTable({required this.year, required this.semester, required this.courses, required this.user}) { - year = year; - semester = semester; - courses = courses; - user = user; weekdays.addAll(courses .map((course) => course.coursePeriods.map((coursePeriod) => coursePeriod.weekday)) .expand((element) => element));