serialize method

  1. @override
String serialize()
override

Implementation

@override
String serialize() {
  final buffer = StringBuffer();
  buffer.write('BEGIN:VEVENT\n');
  buffer.write('UID:$uid\n');
  buffer.write('DTSTAMP:${formatDateTime(dtstamp)}\n');
  buffer.write('DTSTART:${formatDateTime(dtstart)}\n');
  buffer.write('DTEND:${formatDateTime(dtend)}\n');
  buffer.write('SUMMARY:$summary\n');
  if (description != null) buffer.write('DESCRIPTION:$description\n');
  if (location != null) buffer.write('LOCATION:$location\n');
  if (status != null) buffer.write('STATUS:${status != null ? Heplers.camelToSnake(status!.name).toUpperCase() : null}\n');
  if (rrule != null) buffer.write('RRULE:${rrule!.serialize()}\n');
  if (exDates != null) {
    for (var date in exDates!) {
      buffer.write('EXDATE:${formatDateTime(date)}\n');
    }
  }
  if (attendees != null) {
    for (var attendee in attendees!) {
      buffer.write('ATTENDEE:$attendee\n');
    }
  }
  if (organizer != null) buffer.write('ORGANIZER:$organizer\n');
  if (contact != null) buffer.write('CONTACT:$contact\n');
  if (attachment != null) buffer.write('ATTACH:$attachment\n');
  buffer.write('END:VEVENT');
  return buffer.toString();
}