updateContactPointPeriod method

Person updateContactPointPeriod(
  1. Period period, [
  2. int index = 0
])

Implementation

Person updateContactPointPeriod(Period period, [int index = 0]) {
  if (telecom == null || telecom!.isEmpty) {
    return copyWith(telecom: <ContactPoint>[ContactPoint(period: period)]);
  } else if (index >= telecom!.length) {
    return copyWith(
        telecom: <ContactPoint>[...telecom!, ContactPoint(period: period)]);
  } else {
    return copyWith(telecom: <ContactPoint>[
      ...telecom!.sublist(0, index),
      telecom![index].copyWith(period: period),
      ...telecom!.sublist(index + 1)
    ]);
  }
}