getPacketLength static method
Retorna o tamanho total do pacote (cabeçalho de 4 bytes + payload).
Lê os 3 primeiros bytes do buffer
para calcular payloadLength
e soma 4 (bytes do cabeçalho).
Implementation
static int getPacketLength(Uint8List buffer) {
var header = ByteData(4)
..setUint8(0, buffer[0])
..setUint8(1, buffer[1])
..setUint8(2, buffer[2])
..setUint8(3, 0);
final payloadLength = header.getUint32(0, Endian.little);
return payloadLength + 4;
}