removeLastWhere method

bool removeLastWhere({
  1. bool removeIf(
    1. T item
    )?,
  2. T? removeItem,
})

Implementation

bool removeLastWhere({bool removeIf(T item)?, T? removeItem}) {
  assert(removeIf != null || removeItem != null);
  assert(removeIf == null || removeItem == null);

  if (this == null) return false;
  int lastIndex = this!.lastIndexWhere((item) {
    return removeItem != null ? removeItem == item : removeIf!(item);
  });

  if (lastIndex >= 0) {
    this!.removeAt(lastIndex);
    return true;
  } else {
    return false;
  }
}