retrieveEvents method

  1. @override
Future<Iterable<ETEvent>> retrieveEvents({
  1. required String calendarId,
  2. DateTime? startDate,
  3. DateTime? endDate,
})

Retrieves a list of events from the calendar with the given calendarId. Optionally, you can provide a startDate and endDate to filter the events.

Returns a list of Events.

Throws a ETPermissionException if the user refuses to grant calendar permissions.

Throws a ETNotFoundException if the calendar with the given calendarId is not found.

Throws a ETGenericException if any other error occurs during events retrieval.

Implementation

@override
Future<Iterable<ETEvent>> retrieveEvents({required String calendarId, DateTime? startDate, DateTime? endDate}) async {
  try {
    final start = (startDate ?? DateTime.now()).toUtc();
    final end = (endDate ?? DateTime.now()).toUtc();
    final events = await _calendarApi.retrieveEvents(
      calendarId: calendarId,
      startDate: start.millisecondsSinceEpoch,
      endDate: end.millisecondsSinceEpoch,
    );
    return events.toETEventList();
  } on PlatformException catch (e) {
    throw e.toETException();
  }
}