updateAddressText method

Organization updateAddressText(
  1. String text, [
  2. int index = 0
])

Implementation

Organization updateAddressText(String text, [int index = 0]) {
  if (address == null || address!.isEmpty) {
    return copyWith(address: <Address>[Address(text: text)]);
  } else if (index >= address!.length) {
    return copyWith(address: <Address>[...address!, Address(text: text)]);
  } else {
    return copyWith(address: <Address>[
      ...address!.sublist(0, index),
      address![index].copyWith(text: text),
      ...address!.sublist(index + 1)
    ]);
  }
}