read method Null safety

Uint8Buffer read(
  1. int count

Reads a sequence of bytes from the current buffer and advances the position within the buffer by the number of bytes read.


typed.Uint8Buffer read(int count) {
  if ((length < count) || (_position + count) > length) {
    throw Exception('mqtt_client::ByteBuffer: The buffer did not have '
        'enough bytes for the read operation '
        'length $length, count $count, position $_position, buffer $buffer');
  final tmp = typed.Uint8Buffer();
  tmp.addAll(buffer!.getRange(_position, _position + count));
  _position += count;
  final tmp2 = typed.Uint8Buffer();
  return tmp2;