toVCard method
Implementation
List<String> toVCard() {
// TEL (V3): https://tools.ietf.org/html/rfc2426#section-3.3.1
// TEL (V4): https://tools.ietf.org/html/rfc6350#section-6.4.1
final v4 = FlutterContacts.config.vCardVersion == VCardVersion.v4;
var s = v4 ? 'TEL;VALUE=uri' : 'TEL';
var types = <String>[];
switch (label) {
case PhoneLabel.faxHome:
types.add('fax');
types.add('home');
break;
case PhoneLabel.faxOther:
types.add('fax');
break;
case PhoneLabel.faxWork:
types.add('fax');
types.add('work');
break;
case PhoneLabel.home:
types.add('home');
break;
case PhoneLabel.iPhone:
case PhoneLabel.main:
types.add('voice');
types.add(v4 ? 'text' : 'msg');
break;
case PhoneLabel.mms:
case PhoneLabel.mobile:
types.add('cell');
types.add(v4 ? 'text' : 'msg');
break;
case PhoneLabel.workMobile:
types.add('cell');
types.add(v4 ? 'text' : 'msg');
types.add('work');
break;
case PhoneLabel.pager:
types.add('pager');
break;
case PhoneLabel.workPager:
types.add('pager');
types.add('work');
break;
default:
}
if (!v4 && isPrimary) {
types.add('pref');
}
if (types.length == 1) {
s += ';TYPE=${types.first}';
} else if (types.length > 1) {
if (v4) {
s += ';TYPE="${types.join(',')}"';
} else {
s += ';TYPE=${types.join(',')}';
}
}
if (v4 && isPrimary) {
s += ';PREF=1';
}
if (v4) {
s += ':tel:${vCardEncode(number)}';
} else {
s += ':${vCardEncode(number)}';
}
return [s];
}