VCardLabel.fromPlainText constructor

VCardLabel.fromPlainText(
  1. String plainText
)

Constructor from the plain text.

Exmaple: LABEL;TYPE=HOME:123 Main St.\nSpringfield, IL 12345\nUSA

Implementation

factory VCardLabel.fromPlainText(String plainText) {
  if (!plainText.startsWith('LABEL')) {
    throw VCardParsingError('Property "label" must starts with "LABEL"');
  }
  final texts = plainText.split(':');
  VCardIdentifier? type;
  final t = texts.first;
  if (t.contains('TYPE=') || t.contains('type=')) {
    type = VCardIdentifier.fromText(t.substring(11));
  }
  return VCardLabel(
    type: type,
    value: texts[1],
  );
}