updateHumanNameSuffix method

Person updateHumanNameSuffix(
  1. List<String> suffix, [
  2. int index = 0
])

Implementation

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