showEventModal method

Future<void> showEventModal(
  1. String id, {
  2. bool edit = false,
})

Shows an event in the OS's native calendar screen, completing when it's dismissed. Any edits the user makes are saved by the OS; this does not report back what changed.

id may be a bare event ID (the series master) or an instance ID (one occurrence). edit only controls whether the modal starts in the editor — the view screen is not read-only and always offers an Edit affordance.

On Android, edit: true is honored inconsistently (Google Calendar opens a blank new-event editor instead); prefer the view modal and let the user tap Edit. See doc/native-ui.md. Requires full access.

Throws DeviceCalendarException with DeviceCalendarError.notFound when the event doesn't exist, and with DeviceCalendarError.operationFailed when a native modal is already showing (one at a time, shared with showCreateEventModal) or there's no Activity/window to present from.

Implementation

Future<void> showEventModal(String id, {bool edit = false}) async {
  await _ensurePermission(CalendarAccessLevel.full);
  try {
    final parsed = InstanceIdParser.parse(id);

    await DeviceCalendarPlusPlatform.instance.showEventModal(
      parsed.eventId,
      parsed.timestamp,
      edit: edit,
    );
  } on PlatformException catch (e, stackTrace) {
    final convertedException =
        PlatformExceptionConverter.convertPlatformException(e);
    if (convertedException != null) {
      Error.throwWithStackTrace(convertedException, stackTrace);
    }
    rethrow;
  }
}