scheduleNotification method

void scheduleNotification(
  1. AppNotification notification,
  2. DateTime scheduledFor
)

Schedules a notification for future delivery.

Implementation

void scheduleNotification(
  AppNotification notification,
  DateTime scheduledFor,
) {
  final delay = scheduledFor.difference(DateTime.now());
  if (delay.isNegative) {
    show(notification);
    return;
  }

  _scheduledTimers[notification.id]?.cancel();
  _scheduledTimers[notification.id] = Timer(delay, () {
    show(notification);
    _scheduledTimers.remove(notification.id);
  });
}