findIndex method

int findIndex(
  1. ConditionTester<T> test
)

Finds the index of the first element that satisfies the given predicate.

Returns the index of the first element in the iterable that matches the provided test function. Returns -1 if no such element is found.

Implementation

int findIndex(ConditionTester<T> test) {
  for (var i = 0; i < length; i++) {
    if (test(elementAt(i))) {
      return i;
    }
  }
  return -1;
}