updateAddressCountry method

Patient updateAddressCountry(
  1. String country, [
  2. int index = 0
])

Implementation

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