diff --git a/lib/components/subject_management/subject_screen.dart b/lib/components/subject_management/subject_screen.dart index e0a8c34..c51c32b 100644 --- a/lib/components/subject_management/subject_screen.dart +++ b/lib/components/subject_management/subject_screen.dart @@ -205,7 +205,7 @@ class SubjectScreen extends HookConsumerWidget { ); return; } - subjectNotifier.addSubject(newSubject.toCompanion(false)); + subjectNotifier.addSubject(newSubject.toCompanion(true)); Navigator.pop(context, label.value); } if (!isSubjectNull) { diff --git a/lib/db/converters/time_of_day_converter.dart b/lib/db/converters/time_of_day_converter.dart index 619e767..fec2c45 100644 --- a/lib/db/converters/time_of_day_converter.dart +++ b/lib/db/converters/time_of_day_converter.dart @@ -6,16 +6,20 @@ class TimeOfDayConverter extends TypeConverter { @override TimeOfDay fromSql(String fromDb) { - // Parse TimeOfDay from String - return TimeOfDay( - hour: int.parse(fromDb.split(':')[0].replaceAll("TimeOfDay(", "")), - minute: int.parse(fromDb.split(':')[1].replaceAll(")", "")), - ); + String timeOnly = fromDb.substring(10, fromDb.length - 1); + + List parts = timeOnly.split(":"); + int hour = int.parse(parts[0]); + int minute = int.parse(parts[1]); + + TimeOfDay timeOfDay = TimeOfDay(hour: hour, minute: minute); + + return timeOfDay; } @override String toSql(TimeOfDay value) { // Convert TimeOfDay to String - return value.toString(); + return "TimeOfDay(${value.hour}:${value.minute})"; } }