indexOfFirst method

int indexOfFirst(
  1. bool predicate(
    1. T
    )
)

Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.

Implementation

int indexOfFirst(bool Function(T) predicate) {
  var index = 0;
  for (final item in iter) {
    if (predicate(item)) {
      return index;
    }
    index++;
  }
  return -1;
}