listIndexOf method

int? listIndexOf(
  1. List<int> other, [
  2. int start = 0
])

Implementation

int? listIndexOf(List<int> other, [int start = 0]) {
  if (other.length + start > length) {
    return null;
  }
  for (var i = start; i < length - other.length; i++) {
    if (this[i] == other[0]) {
      var found = true;
      for (var j = 1; j < other.length; j++) {
        if (this[i + j] != other[j]) {
          found = false;
          break;
        }
      }
      if (found) {
        return i;
      }
    }
  }
  return null;
}