|
|
|
|
@ -5,6 +5,7 @@ import 'dart:ui';
|
|
|
|
|
|
|
|
|
|
import 'package:device_calendar/device_calendar.dart';
|
|
|
|
|
import 'package:manage_calendar_events/manage_calendar_events.dart' as ios;
|
|
|
|
|
import 'package:timezone/data/latest.dart' as tzl;
|
|
|
|
|
|
|
|
|
|
final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin();
|
|
|
|
|
final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
|
|
|
|
|
@ -44,6 +45,7 @@ class CalendarUtils {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
static Future<CalendarUtils> getInstance() async {
|
|
|
|
|
tzl.initializeTimeZones();
|
|
|
|
|
if (_completer != null) {
|
|
|
|
|
return _completer!.future;
|
|
|
|
|
}
|
|
|
|
|
@ -108,10 +110,10 @@ class CalendarUtils {
|
|
|
|
|
|
|
|
|
|
TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation);
|
|
|
|
|
|
|
|
|
|
print("writableCalendars-name: " + writableCalendars.name);
|
|
|
|
|
print("writableCalendars-Id: " + writableCalendars.id);
|
|
|
|
|
print("writableCalendarsToString: " + writableCalendars.toString());
|
|
|
|
|
print("writableCalendarsToString: " + writableCalendars!.id!);
|
|
|
|
|
print("writableCalendars-name: " + writableCalendars.name);
|
|
|
|
|
print("writableCalendars-Id: " + writableCalendars.id);
|
|
|
|
|
print("writableCalendarsToString: " + writableCalendars.toString());
|
|
|
|
|
print("writableCalendarsToString: " + writableCalendars!.id!);
|
|
|
|
|
Event event = Event(
|
|
|
|
|
writableCalendars!.id,
|
|
|
|
|
start: scheduleDateTimeUTZ,
|
|
|
|
|
@ -120,8 +122,10 @@ class CalendarUtils {
|
|
|
|
|
description: description,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ios.CalendarEvent iosCalEvent =
|
|
|
|
|
ios.CalendarEvent(eventId: eventId, startDate: scheduleDateTimeUTZ, endDate: scheduleDateTimeUTZ.add(Duration(minutes: 30)), title: title, description: description, isAllDay: false);
|
|
|
|
|
|
|
|
|
|
if(Platform.isAndroid) {
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
Result<bool> result = await deviceCalendarPlugin.hasPermissions();
|
|
|
|
|
print(result);
|
|
|
|
|
await deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) {
|
|
|
|
|
@ -129,11 +133,15 @@ class CalendarUtils {
|
|
|
|
|
}).whenComplete(() {
|
|
|
|
|
print("whenComplete Calender ID " + eventId!);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Result<bool> result = await deviceCalendarPlugin.hasPermissions();
|
|
|
|
|
// print(result);
|
|
|
|
|
await _myPlugin.createEvent(calendarId: writableCalendars.id!, event: iosCalEvent).catchError((e) {
|
|
|
|
|
print("catchError " + e.toString());
|
|
|
|
|
}).whenComplete(() {
|
|
|
|
|
print("whenComplete Calender ID iOS " + eventId!);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteEvent(Calendar _calendar, Event _event) async {
|
|
|
|
|
|