findIndex function

int findIndex(
  1. List array,
  2. Function predicate
)

This method is like _.find except that it returns the index of the first element predicate returns truthy for instead of the element itself.

Implementation

int findIndex(List array, Function predicate) {
  for (var i = 0; i < array.length; i++) {
    if (predicate(array[i])) {
      return i;
    }
  }
  return -1;
}