lastIndexOf function

int lastIndexOf(
  1. List array,
  2. dynamic value,
  3. [int? fromIndex]
)

This method is like _.indexOf except that it iterates over elements of array from right to left.

Implementation

int lastIndexOf(List array, value, [int? fromIndex]) {
  var result = 0;
  fromIndex ??= array.length - 1;
  for (var i = fromIndex; i >= 0; i--) {
    if (array[i] == value) {
      result = i;
      return result;
    }
  }
  return result;
}