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