copyWithReplacedWhere method
Returns a copy with the first element matching test replaced
Implementation
List<T> copyWithReplacedWhere(bool Function(T item) test, T newItem) {
final index = indexWhere(test);
if (index == -1) return List.of(this);
return [...sublist(0, index), newItem, ...sublist(index + 1)];
}