dropWhile method

List<E> dropWhile(
  1. bool predicate(
    1. E element
    )
)

Returns a new list containing all elements except last elements that satisfy the given predicate.

Implementation

List<E> dropWhile(bool Function(E element) predicate) {
  int? startIndex;
  for (var i = 0; i < length; i++) {
    if (!predicate(this[i])) {
      startIndex = i;
      break;
    }
  }
  if (startIndex == null) return [];
  return sublist(startIndex);
}