updateHumanNamePeriod method

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

Implementation

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