schedule static method

Future<bool> schedule(
  1. UNotificationRequest request,
  2. DateTime at, {
  3. URepeat repeat = URepeat.none,
  4. URepeatCalendar calendar = URepeatCalendar.gregorian,
  5. bool exact = true,
})

Shows request at at, optionally repeating. Survives restarts (and reboots on Android).

Implementation

static Future<bool> schedule(
  UNotificationRequest request,
  DateTime at, {
  URepeat repeat = URepeat.none,
  URepeatCalendar calendar = URepeatCalendar.gregorian,
  bool exact = true,
}) async {
  await init();
  final UNotificationRequest ready = await _prepare(request);
  final Map<String, Object?> record = <String, Object?>{
    "request": ready.toMap(),
    "at": at.millisecondsSinceEpoch,
    "repeat": repeat.name,
    "calendar": calendar.name,
  };
  if (_softScheduler) {
    await _store(ready.id, record);
    _arm(ready.id, record);
    return true;
  }
  if (_needsBatch(record)) {
    await _store(ready.id, record);
    return _scheduleBatch(ready.id, record);
  }
  return await _call<bool>("schedule", <String, Object?>{...record, "exact": exact}) ?? false;
}