listSources method

Future<List<CalendarSource>> listSources()

Lists the accounts (iCloud, Google, local…) that calendars can be created under. Pass a source to createCalendar via CreateCalendarOptionsIos or CreateCalendarOptionsAndroid to target a specific account.

On Android, only sources that already have a calendar are returned. Requires full access.

Implementation

Future<List<CalendarSource>> listSources() async {
  await _ensurePermission(CalendarAccessLevel.full);
  try {
    final List<Map<String, dynamic>> rawSources =
        await DeviceCalendarPlusPlatform.instance.listSources();
    return rawSources.map((map) => CalendarSource.fromMap(map)).toList();
  } on PlatformException catch (e, stackTrace) {
    final convertedException =
        PlatformExceptionConverter.convertPlatformException(e);
    if (convertedException != null) {
      Error.throwWithStackTrace(convertedException, stackTrace);
    }
    rethrow;
  }
}