parse static method

Attendee parse(
  1. String attendeeString
)

Implementation

static Attendee parse(String attendeeString) {
  final lines = attendeeString.split(';');
  Map<String,dynamic> attendeeJson={};
  for (String line in lines) {
    final parts = line.split(':');
    if (parts.length == 2) {
      final key = parts[0];
      final value = parts.getRange(1, parts.length).join(':');
      attendeeJson[key]=value;
    }
  }
  if(attendeeJson['mailto'] != null){
    return Attendee(
      mailto: MailTo.parse(attendeeJson['mailto']),
      cn: attendeeJson['CN'],
      role: attendeeJson['ROLE'] != null ? Role.values.firstWhere((e)=>e.name == Heplers.toCamelCase(attendeeJson['ROLE'])) : null,
      rsvp: attendeeJson['RSVP'] != null ? attendeeJson['RSVP'] == 'TRUE' : null,
      partstat: attendeeJson['PARTSTAT'] != null ? Partstat.values.firstWhere((e)=>e.name == Heplers.toCamelCase(attendeeJson['PARTSTAT'])) : null,
      cutype: attendeeJson['CUTYPE'] != null ? Cutype.values.firstWhere((e) => e.name == Heplers.toCamelCase(attendeeJson['CUTYPE'])) : null,
      delegatedTo: attendeeJson['DELEGATED-TO'],
      delegatedFrom: attendeeJson['DELEGATED-FROM']
    );
  }
  throw 'Unable to parse Attendee';
}