getCharCount method Null safety

int getCharCount(
  1. Uint8Buffer bytes
)

When overridden in a derived class, calculates the number of characters produced by decoding all the bytes in the specified byte array.

Implementation

int getCharCount(typed.Uint8Buffer bytes) {
  if (bytes.length < 2) {
    throw Exception(
        'mqtt_client::MQTTEncoding: Length byte array must comprise 2 bytes');
  }
  return (bytes[0] << 8) + bytes[1];
}