getBytes method

ByteData getBytes(
  1. int length
)

This method transfers bytes from this reader into the ByteData.

The length is the maximum number of bytes to be written to the ByteData return the target byte data

Implementation

ByteData getBytes(int length) {
  if (_position + length > _lengthInBytes) {
    throw ArgumentError(
        "illegal read length : position = $_position, length = $length, total buffer length =$_lengthInBytes");
  }
  var byteData = Uint8List(length);
  var index = 0;
  for (var i = _position, j = _position + length; i < j; i++) {
    byteData[index++] = _bytes[i];
  }
  _position += length;
  return byteData.buffer.asByteData();
}