copyWithReplacedAll method

List<T> copyWithReplacedAll(
  1. T oldItem,
  2. T newItem
)

Returns a copy with all occurrences of oldItem replaced

Implementation

List<T> copyWithReplacedAll(T oldItem, T newItem) {
  return map((e) => e == oldItem ? newItem : e).toList();
}