copyWithReplaced method
Returns a copy with the first occurrence of oldItem replaced
Implementation
List<T> copyWithReplaced(T oldItem, T newItem) {
final index = indexOf(oldItem);
if (index == -1) return List.of(this);
return [...sublist(0, index), newItem, ...sublist(index + 1)];
}