serialize method

  1. @override
String serialize()
override

Implementation

@override
String serialize() {
  final buffer = StringBuffer();
  buffer.write('BEGIN:VTODO\n');
  buffer.write('UID:$uid\n');
  buffer.write('DTSTAMP:${formatDateTime(dtstamp)}\n');
  buffer.write('SUMMARY:$summary\n');
  buffer.write('DUE:${formatDateTime(due)}\n');
  if (description != null) buffer.write('DESCRIPTION:$description\n');
  if (status != null) buffer.write('STATUS:${status != null ? Heplers.camelToSnake(status!.name).toUpperCase() : null}\n');
  if (priority != null) buffer.write('PRIORITY:$priority\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');
  buffer.write('END:VTODO');
  return buffer.toString();
}