showWeeklyAtDayAndTime method

int showWeeklyAtDayAndTime(
  1. Day? day,
  2. TZDateTime? schedule, {
  3. int? id,
  4. String? title,
  5. String? body,
  6. String? payload,
  7. bool? androidAllowWhileIdle,
  8. NotificationDetails? notificationDetails,
  9. UILocalNotificationDateInterpretation? uiLocalNotificationDateInterpretation,
  10. DateTimeComponents? matchDateTimeComponents,
  11. String? icon,
  12. Importance? importance,
  13. Priority? priority,
  14. StyleInformation? styleInformation,
  15. bool? playSound,
  16. AndroidNotificationSound? sound,
  17. bool? enableVibration,
  18. List<int>? vibrationPattern,
  19. String? groupKey,
  20. bool? setAsGroupSummary,
  21. GroupAlertBehavior? groupAlertBehavior,
  22. bool? autoCancel,
  23. bool? ongoing,
  24. Color? color,
  25. AndroidBitmap<Object>? largeIcon,
  26. bool? onlyAlertOnce,
  27. bool? showWhen,
  28. int? when,
  29. bool? usesChronometer,
  30. bool? channelShowBadge,
  31. bool? showProgress,
  32. int? maxProgress,
  33. int? progress,
  34. bool? indeterminate,
  35. AndroidNotificationChannelAction? channelAction,
  36. bool? enableLights,
  37. Color? ledColor,
  38. int? ledOnMs,
  39. int? ledOffMs,
  40. String? ticker,
  41. NotificationVisibility? visibility,
  42. int? timeoutAfter,
  43. String? category,
  44. bool? fullScreenIntent,
  45. String? shortcutId,
  46. Int32List? additionalFlags,
  47. String? subText,
  48. String? tag,
  49. bool? presentAlert,
  50. bool? presentSound,
  51. bool? presentBadge,
  52. String? soundFile,
  53. int? badgeNumber,
  54. List<IOSNotificationAttachment>? attachments,
  55. List<MacOSNotificationAttachment>? macAttachments,
  56. String? subtitle,
  57. String? threadIdentifier,
})

Show a Notifications weekly on a specific day and time.

Implementation

int showWeeklyAtDayAndTime(
  Day? day,
  TZDateTime? schedule, {
  int? id,
  String? title,
  String? body,
  String? payload,
  bool? androidAllowWhileIdle,
  NotificationDetails? notificationDetails,
  UILocalNotificationDateInterpretation?
      uiLocalNotificationDateInterpretation,
  DateTimeComponents? matchDateTimeComponents,
  String? icon,
  Importance? importance,
  Priority? priority,
  StyleInformation? styleInformation,
  bool? playSound,
  AndroidNotificationSound? sound,
  bool? enableVibration,
  List<int>? vibrationPattern,
  String? groupKey,
  bool? setAsGroupSummary,
  GroupAlertBehavior? groupAlertBehavior,
  bool? autoCancel,
  bool? ongoing,
  Color? color,
  AndroidBitmap<Object>? largeIcon,
  bool? onlyAlertOnce,
  bool? showWhen,
  int? when,
  bool? usesChronometer,
  bool? channelShowBadge,
  bool? showProgress,
  int? maxProgress,
  int? progress,
  bool? indeterminate,
  AndroidNotificationChannelAction? channelAction,
  bool? enableLights,
  Color? ledColor,
  int? ledOnMs,
  int? ledOffMs,
  String? ticker,
  NotificationVisibility? visibility,
  int? timeoutAfter,
  String? category,
  bool? fullScreenIntent,
  String? shortcutId,
  Int32List? additionalFlags,
  String? subText,
  String? tag,
  bool? presentAlert,
  bool? presentSound,
  bool? presentBadge,
  String? soundFile,
  int? badgeNumber,
  List<IOSNotificationAttachment>? attachments,
  List<MacOSNotificationAttachment>? macAttachments,
  String? subtitle,
  String? threadIdentifier,
}) {
  //
  day ??= _day;

  if (schedule == null && _schedule != null) {
    schedule ??= _schedule as TZDateTime;
  }

  if (day == null || schedule == null) {
    return -1;
  }

  //
  final notificationSpecifics = _notificationDetails(
    title,
    body,
    payload,
    androidAllowWhileIdle,
    icon,
    importance,
    priority,
    styleInformation,
    playSound,
    sound,
    enableVibration,
    vibrationPattern,
    groupKey,
    setAsGroupSummary,
    groupAlertBehavior,
    autoCancel,
    ongoing,
    color,
    largeIcon,
    onlyAlertOnce,
    showWhen,
    when,
    usesChronometer,
    channelShowBadge,
    showProgress,
    maxProgress,
    progress,
    indeterminate,
    channelAction,
    enableLights,
    ledColor,
    ledOnMs,
    ledOffMs,
    ticker,
    visibility,
    timeoutAfter,
    category,
    fullScreenIntent,
    shortcutId,
    additionalFlags,
    subText,
    tag,
    presentAlert,
    presentSound,
    presentBadge,
    soundFile,
    badgeNumber,
    attachments,
    macAttachments,
    subtitle,
    threadIdentifier,
  );

  if (notificationSpecifics == null) {
    id = -1;
  } else {
    //
    try {
      //
      if (id == null || id < 0) {
        id = Random().nextInt(999);
      }

      _flutterLocalNotificationsPlugin!.zonedSchedule(
        id,
        title,
        body,
        schedule,
        notificationDetails!,
        uiLocalNotificationDateInterpretation:
            uiLocalNotificationDateInterpretation!,
        androidAllowWhileIdle: androidAllowWhileIdle!,
        payload: payload,
        matchDateTimeComponents: matchDateTimeComponents,
      );
    } catch (ex) {
      id = -1;
      getError(ex);
    }
  }
  return id;
}