updateContactPointSystem method

Organization updateContactPointSystem(
  1. ContactPointSystem system, [
  2. int index = 0
])

Implementation

Organization updateContactPointSystem(ContactPointSystem system,
    [int index = 0]) {
  if (telecom == null || telecom!.isEmpty) {
    return copyWith(telecom: <ContactPoint>[ContactPoint(system: system)]);
  } else if (index >= telecom!.length) {
    return copyWith(
        telecom: <ContactPoint>[...telecom!, ContactPoint(system: system)]);
  } else {
    return copyWith(telecom: <ContactPoint>[
      ...telecom!.sublist(0, index),
      telecom![index].copyWith(system: system),
      ...telecom!.sublist(index + 1)
    ]);
  }
}