counter method

VCalendar counter({
  1. String? comment,
  2. DateTime? start,
  3. DateTime? end,
  4. IsoDuration? duration,
  5. String? location,
  6. String? description,
})

Creates a counter proposal for this calendar.

Optionally specify the rationale for the change in comment. You can also set a different start, end, duration, location or description directly. Any other changes have to be done directly on the children of the returned VCalendar. Any attendee can propose a counter, for example with different time, location or attendees. The method is set to Method.counter, the VEvent.sequence stays the same, but the VEvent.timeStamp is updated.

Compare declineCounter for organizers to decline a counter proposal.

Implementation

VCalendar counter({
  String? comment,
  DateTime? start,
  DateTime? end,
  IsoDuration? duration,
  String? location,
  String? description,
}) {
  final copied = copy() as VCalendar..method = Method.counter;
  final event =
      copied.children.firstWhereOrNull((ev) => ev is VEvent) as VEvent?;
  if (event != null) {
    event.timeStamp = DateTime.now();
    if (comment != null) {
      event.comment = comment;
    }
    if (location != null) {
      event.location = location;
    }
    if (start != null) {
      event.start = start;
    }
    if (end != null) {
      event.end = end;
    }
    if (duration != null) {
      event.duration = duration;
    }
    if (description != null) {
      event.description = description;
    }
  }

  return copied;
}