createEvent static method
VCalendar
createEvent({
- required DateTime start,
- String? organizerEmail,
- OrganizerProperty? organizer,
- List<
String> ? attendeeEmails, - List<
AttendeeProperty> ? attendees, - bool? rsvp,
- DateTime? end,
- IsoDuration? duration,
- String? location,
- Uri? url,
- String? summary,
- String? description,
- String productId = 'enough_icalendar',
- String? calendarScale,
- String? timezoneId,
- DateTime? timeStamp,
- String? uid,
- bool? isAllDayEvent,
- Method method = Method.request,
Creates an event from the specified organizer
resp. organizerEmail
on the given start
datetime and either the end
or duration
.
Any other settings are optional.
Implementation
static VCalendar createEvent({
required DateTime start,
String? organizerEmail,
OrganizerProperty? organizer,
List<String>? attendeeEmails,
List<AttendeeProperty>? attendees,
bool? rsvp,
DateTime? end,
IsoDuration? duration,
String? location,
Uri? url,
String? summary,
String? description,
String productId = 'enough_icalendar',
String? calendarScale,
String? timezoneId,
DateTime? timeStamp,
String? uid,
bool? isAllDayEvent,
Method method = Method.request,
}) {
assert(organizer != null || organizerEmail != null,
'Either organizer or organizerEmail needs to be specified.');
assert(end != null || duration != null,
'Either end or duration must be specified.');
final calendar = VCalendar()
..calendarScale = calendarScale
..productId = productId
..version = '2.0'
..timezoneId = timezoneId
..method = method;
final event = VEvent(parent: calendar);
calendar.children.add(event);
organizer ??= OrganizerProperty.create(email: organizerEmail);
event
..timeStamp = timeStamp ?? DateTime.now()
..uid = uid ?? createUid(organizerUri: organizer!.uri)
..start = start
..end = end
..duration = duration
..organizer = organizer
..summary = summary
..description = description
..location = location
..url = url
..isAllDayEvent = isAllDayEvent;
if (attendees != null) {
event.attendees = attendees;
} else if (attendeeEmails != null) {
event.attendees = attendeeEmails
.map((email) =>
AttendeeProperty.create(attendeeEmail: email, rsvp: rsvp)!)
.toList();
}
return calendar;
}