|
|
|
|
@ -2,14 +2,16 @@ import 'dart:async';
|
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
|
|
import 'package:device_calendar/device_calendar.dart';
|
|
|
|
|
import 'package:manage_calendar_events/manage_calendar_events.dart' as mcn;
|
|
|
|
|
|
|
|
|
|
final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin();
|
|
|
|
|
final mcn.CalendarPlugin _myPlugin = mcn.CalendarPlugin();
|
|
|
|
|
|
|
|
|
|
class CalendarUtils {
|
|
|
|
|
static Completer<CalendarUtils>? _completer;
|
|
|
|
|
|
|
|
|
|
Calendar? get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
|
|
|
|
|
List<Calendar> calendars;
|
|
|
|
|
mcn.Calendar? get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
|
|
|
|
|
List<mcn.Calendar> calendars;
|
|
|
|
|
|
|
|
|
|
CalendarUtils._(this.calendars);
|
|
|
|
|
|
|
|
|
|
@ -19,9 +21,9 @@ class CalendarUtils {
|
|
|
|
|
if (_completer == null) {
|
|
|
|
|
_completer = await Completer<CalendarUtils>();
|
|
|
|
|
try {
|
|
|
|
|
final calendarsResult = await deviceCalendarPlugin.retrieveCalendars();
|
|
|
|
|
final List<mcn.Calendar>? calendarsResult = await _myPlugin.getCalendars();
|
|
|
|
|
// if (calendarsResult.data != null)
|
|
|
|
|
_completer?.complete(await CalendarUtils._(await calendarsResult.data!));
|
|
|
|
|
_completer?.complete(await CalendarUtils._(await calendarsResult!));
|
|
|
|
|
} on Exception catch (e) {
|
|
|
|
|
_completer!.completeError(e);
|
|
|
|
|
final Future<CalendarUtils> sharedPrefsFuture = _completer!.future;
|
|
|
|
|
@ -88,7 +90,7 @@ class CalendarUtils {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteEvent(Calendar _calendar, Event _event) async {
|
|
|
|
|
deleteEvent(mcn.Calendar _calendar, Event _event) async {
|
|
|
|
|
await deviceCalendarPlugin.deleteEvent(_calendar.id, _event.eventId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|