@andoriyaprashant
Is there an existing issue for this?
What happened?
Inside the build method of OpsoTimeLineScreen (which is a StatelessWidget), the code loops through all timeline events and schedules notifications via NotificationService.scheduleNotificationsForEvent
Now the impact it is causing is the build method in Flutter can run many times (on rotation, theme change, parent widget rebuilds). Running asynchronous side-effects here will trigger multiple duplicate scheduling commands. Because notification IDs are generated using a timestamp (DateTime.now().millisecondsSinceEpoch), this stacks up hundreds of duplicate notifications, causing system slowdowns and eventually flooding the user with identical notifications when they trigger
Suggested fix :
Shift notification scheduling out of the build method. It should either be triggered once at app startup (e.g., inside main.dart) or using a dedicated initialization check. Use static notification IDs based on a hash of the event title/date to overwrite previous updates rather than generating a new ID each time.
Record
@andoriyaprashant
Is there an existing issue for this?
What happened?
Inside the build method of
OpsoTimeLineScreen(which is a StatelessWidget), the code loops through all timeline events and schedules notifications viaNotificationService.scheduleNotificationsForEventNow the impact it is causing is the build method in Flutter can run many times (on rotation, theme change, parent widget rebuilds). Running asynchronous side-effects here will trigger multiple duplicate scheduling commands. Because notification IDs are generated using a timestamp (
DateTime.now().millisecondsSinceEpoch), this stacks up hundreds of duplicate notifications, causing system slowdowns and eventually flooding the user with identical notifications when they triggerSuggested fix :
Shift notification scheduling out of the build method. It should either be triggered once at app startup (e.g., inside main.dart) or using a dedicated initialization check. Use static notification IDs based on a hash of the event title/date to overwrite previous updates rather than generating a new ID each time.
Record