replaceAt method

  1. @useResult
List<T> replaceAt(
  1. int index,
  2. T value
)

New list with element at index replaced by value; no-op if index out of range. Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
List<T> replaceAt(int index, T value) {
  final List<T> out = List<T>.of(this);
  if (index >= 0 && index < length) out[index] = value;
  return out;
}