update method
VCalendar
update({
- Method? method,
- EventStatus? eventStatus,
- String? comment,
- List<
AttendeeProperty> ? addAttendees, - List<
String> ? addAttendeeEmails, - List<
AttendeeProperty> ? removeAttendees, - List<
String> ? removeAttendeesEmails, - bool attendeeFilter()?,
- String? description,
Prepares an update of this calendar.
An organizer can use this to send an updated version around.
Creates a copy with an updated VEvent.timeStamp, an increased
VEvent.sequence and the method
set to Method.request.
All parameters are optional and are applied as a convenience.
Implementation
VCalendar update({
Method? method,
EventStatus? eventStatus,
String? comment,
List<AttendeeProperty>? addAttendees,
List<String>? addAttendeeEmails,
List<AttendeeProperty>? removeAttendees,
List<String>? removeAttendeesEmails,
bool Function(AttendeeProperty)? attendeeFilter,
String? description,
}) {
final copied = copy() as VCalendar;
if (method != null) {
copied.method = method;
}
final event =
copied.children.firstWhereOrNull((ev) => ev is VEvent) as VEvent?;
if (event != null) {
final sequence = event.sequence;
event
..sequence = sequence != null ? sequence + 1 : 1
..timeStamp = DateTime.now();
if (eventStatus != null) {
event.status = eventStatus;
}
if (comment != null) {
event.comment = comment;
}
if (addAttendees != null) {
event.properties.addAll(addAttendees);
}
if (addAttendeeEmails != null) {
for (final email in addAttendeeEmails) {
event.addAttendee(AttendeeProperty.create(attendeeEmail: email)!);
}
}
if (removeAttendees != null) {
for (final prop in removeAttendees) {
event.removeAttendeeWithUri(prop.uri);
}
}
if (removeAttendeesEmails != null) {
removeAttendeesEmails.forEach(event.removeAttendeeWithEmail);
}
if (attendeeFilter != null) {
final attendees = event.attendees;
for (final attendee in attendees) {
if (!attendeeFilter(attendee)) {
event.removeAttendee(attendee);
}
}
}
if (description != null) {
event.description = description;
}
}
return copied;
}