addBirthday method

Future<Result<String>?> addBirthday(
  1. DateTime birthday,
  2. String title,
  3. String description,
  4. String calendarId
)

Adds a birthday event to the user's calendar.

The birthday is added with a yearly recurrence rule to the calendar with the calendarId. The title and description are used for the event.

Returns the event id if the event was successfully added.

Implementation

Future<Result<String>?> addBirthday(
  DateTime birthday,
  String title,
  String description,
  String calendarId,
) async {
  final startDate = TZDateTime(
    getLocation('Europe/Amsterdam'),
    DateTime.now().year,
    birthday.month,
    birthday.day,
  );

  return deviceCalendarPlugin.createOrUpdateEvent(
    Event(
      calendarId,
      title: title,
      description: description,
      start: startDate,
      end: startDate.add(const Duration(minutes: 30)),
      allDay: true,
      recurrenceRule: RecurrenceRule(
        RecurrenceFrequency.Yearly,
      ),
    ),
  );
}