updateAddressCity method
Implementation
Person updateAddressCity(String city, [int index = 0]) {
if (address == null || address!.isEmpty) {
return copyWith(address: <Address>[Address(city: city)]);
} else if (index >= address!.length) {
return copyWith(address: <Address>[...address!, Address(city: city)]);
} else {
return copyWith(address: <Address>[
...address!.sublist(0, index),
address![index].copyWith(city: city),
...address!.sublist(index + 1)
]);
}
}