Description
I was going through isar_provider.dart and noticed thatt doesAlarmExist prints alarms[0].alarmID even before checking if the list is actually non-empty.
So if the alarm doesnot exist in Isar , alarms comes back empty and that line crashes and gives a RangeError.
Affected Code
lib/app/data/providers/isar_provider.dart ~line 342
final alarms = await db.alarmModels.where().filter().alarmIDEqualTo(alarmID).findAll();
print('checkEmpty ${alarms[0].alarmID} ${alarms.isNotEmpty}'); // crashes if alarms is empty
return alarms.isNotEmpty;
Why it matters
This method is called in
add_or_update_alarm_controller.dart
at lines 652 and 663, during both alarm creation and update. So on a fresh install when an alarm doesn't exist yet, trying to create an alarm could hit this crash path.
Fix
Just move the print inside an isNotEmpty check:
if (alarms.isNotEmpty) { print('checkEmpty ${alarms[0].alarmID} ${alarms.isNotEmpty}'); } return alarms.isNotEmpty;
Description
I was going through isar_provider.dart and noticed thatt doesAlarmExist prints
alarms[0].alarmIDeven before checking if the list is actually non-empty.So if the alarm doesnot exist in Isar , alarms comes back empty and that line crashes and gives a
RangeError.Affected Code
lib/app/data/providers/isar_provider.dart ~line 342
Why it matters
This method is called in
add_or_update_alarm_controller.dartat lines 652 and 663, during both alarm creation and update. So on a fresh install when an alarm doesn't exist yet, trying to create an alarm could hit this crash path.
Fix
Just move the print inside an isNotEmpty check:
if (alarms.isNotEmpty) { print('checkEmpty ${alarms[0].alarmID} ${alarms.isNotEmpty}'); } return alarms.isNotEmpty;