indexOfLast method

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

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

Implementation

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