createEvent method
Helps to create an event in the selected calendar
Implementation
Future<String?> createEvent({
required String calendarId,
required CalendarEvent event,
}) async {
String? eventId;
try {
eventId = await _channel.invokeMethod(
'createEvent',
<String, Object?>{
'calendarId': calendarId,
'eventId': event.eventId != null ? event.eventId : null,
'title': event.title,
'description': event.description,
'startDate': event.startDate!.millisecondsSinceEpoch,
'endDate': event.endDate!.millisecondsSinceEpoch,
'location': event.location,
'isAllDay': event.isAllDay != null ? event.isAllDay : false,
'hasAlarm': event.hasAlarm != null ? event.hasAlarm : false,
'url': event.url,
'reminder': event.reminder != null ? event.reminder!.minutes : null,
'attendees': event.attendees != null
? event.attendees!.attendees
.map((attendee) => attendee.toJson())
.toList()
: null,
},
);
} catch (e) {
print(e);
}
return eventId;
}