indexOfLast method

int indexOfLast(
  1. bool test(
    1. E element
    )
)

Returns index of the last element passing the given test, or -1 if the collection does not contain such element.

Implementation

int indexOfLast(bool Function(E element) test) {
  var lastIndex = -1;
  var index = 0;

  for (final element in this) {
    if (test(element)) lastIndex = index;
    index++;
  }

  return lastIndex;
}