toVCard method

List<String> toVCard()

Implementation

List<String> toVCard() {
  // ADR (V3): https://tools.ietf.org/html/rfc2426#section-3.2.1
  // ADR (V4): https://tools.ietf.org/html/rfc6350#section-6.3.1
  var s = 'ADR';
  if (FlutterContacts.config.vCardVersion == VCardVersion.v3) {
    switch (label) {
      case AddressLabel.home:
        s += ';TYPE=home';
        break;
      case AddressLabel.work:
        s += ';TYPE=work';
        break;
      default:
    }
  } else {
    switch (label) {
      case AddressLabel.home:
        s += ';LABEL=home';
        break;
      case AddressLabel.school:
        s += ';LABEL=school';
        break;
      case AddressLabel.work:
        s += ';LABEL=work';
        break;
      case AddressLabel.other:
        s += ';LABEL=other';
        break;
      case AddressLabel.custom:
        s += ';LABEL="${vCardEncode(customLabel)}"';
        break;
    }
  }
  if (street.isNotEmpty ||
      pobox.isNotEmpty ||
      city.isNotEmpty ||
      state.isNotEmpty ||
      postalCode.isNotEmpty) {
    s += ':${vCardEncode(pobox)};;'
        '${vCardEncode(street)};'
        '${vCardEncode(city)};'
        '${vCardEncode(state)};'
        '${vCardEncode(postalCode)};'
        '${vCardEncode(country)}';
  } else {
    s += ':;;${vCardEncode(address)};;;;';
  }
  return [s];
}