indexOf method

  1. @override
int indexOf(
  1. int byte, [
  2. int offset = 0,
  3. int? length
])
override

Returns the index of byte inf offset and length range.

Implementation

@override
int indexOf(int byte, [int offset = 0, int? length]) {
  if (offset >= _length) return -1;

  length ??= _length - offset;

  var end = offset + length;
  if (end > _length) {
    end = _length;
  }

  if (end == _bytes.length) {
    return _bytes.indexOf(byte, offset);
  }

  for (var i = offset; i < end; ++i) {
    var b = _bytes[i];
    if (b == byte) return i;
  }

  return -1;
}