updateContactPointUse method

RelatedPerson updateContactPointUse(
  1. ContactPointUse use, [
  2. int index = 0
])

Implementation

RelatedPerson updateContactPointUse(ContactPointUse use, [int index = 0]) {
  if (telecom == null || telecom!.isEmpty) {
    return copyWith(telecom: <ContactPoint>[ContactPoint(use: use)]);
  } else if (index >= telecom!.length) {
    return copyWith(
        telecom: <ContactPoint>[...telecom!, ContactPoint(use: use)]);
  } else {
    return copyWith(telecom: <ContactPoint>[
      ...telecom!.sublist(0, index),
      telecom![index].copyWith(use: use),
      ...telecom!.sublist(index + 1)
    ]);
  }
}