replaceAll method

List<T> replaceAll(
  1. T function(
    1. T element
    )
)

Edit all elements of a list.

List<String> users = ['john', 'william', 'david'];
users.replaceAll( (user) => user.toUpperCase());
print(users); // ['JHON', 'WILLIAM', 'DAVID'];

Implementation

List<T> replaceAll(T Function(T element) function) {
  for (var i = 0; i < length; i++) {
    this[i] = function(this[i]);
  }
  return this;
}