update method

List<T> update(
  1. bool condition(
    1. T
    ),
  2. T updater(
    1. T
    )
)

Update a list of items based on a condition.

Implementation

List<T> update(bool Function(T) condition, T Function(T) updater) {
  return map((item) {
    if (condition(item)) {
      return updater(item);
    }
    return item;
  }).toList();
}