createEventThroughNativePlatform method

  1. @override
Future<void> createEventThroughNativePlatform({
  1. String? title,
  2. DateTime? startDate,
  3. DateTime? endDate,
  4. bool? isAllDay,
  5. String? description,
  6. String? url,
  7. String? location,
  8. Iterable<Duration>? reminders,
})

Creates a new event through the native platform's event creation UI with optional title, startDate, endDate, description, url, location, and a list of reminders duration.

/!\ Note that a Duration in seconds will not be supported by Android for API limitations.

This method does not guarantee that an event will be created, as the user may cancel the operation. If the user creates an event, it will be added to the selected calendar. If the user cancels the operation, no event will be created.

Throws a ETPresentationException if there is an error presenting the native event creation UI.

Throws a ETUserCanceledException if the user cancels the event creation.

Throws a ETEventDeletedException if the event is deleted during the creation

Throws a ETGenericException if any other error occurs during event creation.

Not that this is a fire and forget method on Android. It will not wait the event creation to be done to return, so nothing will happen after this method call. It is the same Android native implementation as createEventInDefaultCalendar.

Implementation

@override
Future<void> createEventThroughNativePlatform({
  String? title,
  DateTime? startDate,
  DateTime? endDate,
  bool? isAllDay,
  String? description,
  String? url,
  String? location,
  Iterable<Duration>? reminders,
}) async {
  try {
    await _calendarApi.createEventThroughNativePlatform(
      title: title,
      startDate: startDate?.toUtc().millisecondsSinceEpoch,
      endDate: endDate?.toUtc().millisecondsSinceEpoch,
      isAllDay: isAllDay,
      description: description,
      url: url,
      location: location,
      reminders: reminders?.map((e) => e.toNativeDuration()).toList(),
    );
  } on PlatformException catch (e) {
    throw e.toETException();
  }
}