dropRightWhen<T> function

void dropRightWhen<T>(
  1. List<T>? list,
  2. bool call(
    1. T,
    2. int,
    3. List<T>
    )
)

Implementation

void dropRightWhen<T>(List<T>? list, bool Function(T, int, List<T>) call) {
  if (list == null) {
    return;
  }
  int i = 0;
  for (; i < list.length; i++) {
    var v = list[i];
    if (call.call(v, i, list)) {
      break;
    }
  }
  list.removeRange(i + 1, list.length);
}