parseRFC5545String function

RecurrenceRule? parseRFC5545String(
  1. String rfc5545string
)

Implementation

RecurrenceRule? parseRFC5545String(String rfc5545string) {
  final lines = rfc5545string.split('\n');
  DateTime? startDate;
  bool? isLocal;
  RecurrenceRule? rrule;
  Set<DateTime>? excludedDates;
  for (String line in lines) {
    final header = _inspectHeader(line);
    if (header == null) {
      rrule = _parseRRule(line);
      continue;
    }
    switch (header.toUpperCase()) {
      case 'RRULE':
        rrule = _parseRRule(line);
        break;
      case 'EXDATE':
        excludedDates = _parseExDates(line);
        break;
      case 'DTSTART':
        final parsedResult = _parseStartDate(line);
        startDate = parsedResult?.$1;
        isLocal = parsedResult?.$2;
        break;
      default:
        throw UnsupportedError(
            'Unsupported header of $header in rfc5545 string');
    }
  }
  return rrule?.copyWith(
      startDate: startDate, isLocal: isLocal, excludedDates: excludedDates);
}