lengthUntilZero method
Returns the number of bytes before the next zero byte.
If maxLength is null, throws RawReaderException if zero is not found.
Otherwise returns `maxLength if zero is not found.
Implementation
int lengthUntilZero({int? maxLength}) {
final byteData = this._byteData;
final start = this.index;
int end;
if (maxLength == null) {
end = _byteData.lengthInBytes;
} else {
end = start + maxLength;
}
for (var i = start; i < end; i++) {
if (byteData.getUint8(i) == 0) {
return i - start;
}
}
if (maxLength != null) {
return maxLength;
}
throw _eofException(start, "sequence of bytes terminated by zero");
}