toVCard method

List<String> toVCard()

Implementation

List<String> toVCard() {
  // N (V3): https://tools.ietf.org/html/rfc2426#section-3.1.2
  // NICKNAME (V3): https://tools.ietf.org/html/rfc2426#section-3.1.3
  // N (V4): https://tools.ietf.org/html/rfc6350#section-6.2.2
  // NICKNAME (V4): https://tools.ietf.org/html/rfc6350#section-6.2.3
  var lines = <String>[];
  final components = [last, first, middle, prefix, suffix];
  if (components.any((x) => x.isNotEmpty)) {
    lines.add('N:' + components.map(vCardEncode).join(';'));
  }
  if (nickname.isNotEmpty) {
    lines.add('NICKNAME:' + vCardEncode(nickname));
  }
  return lines;
}