MySQLPacket.decodeCommPrepareStmtResponsePacket constructor
MySQLPacket.decodeCommPrepareStmtResponsePacket(
- Uint8List buffer
Implementation
factory MySQLPacket.decodeCommPrepareStmtResponsePacket(Uint8List buffer) {
final byteData = ByteData.sublistView(buffer);
int offset = 0;
final header = MySQLPacket.decodePacketHeader(buffer);
offset += 4;
final payloadLength = header.item1;
final sequenceNumber = header.item2;
final type = byteData.getUint8(offset);
MySQLPacketPayload payload;
if (type == 0x00) {
// OK packet
payload = MySQLPacketStmtPrepareOK.decode(
Uint8List.sublistView(buffer, offset),
);
} else if (type == 0xff) {
payload = MySQLPacketError.decode(Uint8List.sublistView(buffer, offset));
} else {
throw MySQLProtocolException(
"Unexpected header type while decoding COM_STMT_PREPARE response: $header",
);
}
return MySQLPacket(
sequenceID: sequenceNumber,
payloadLength: payloadLength,
payload: payload,
);
}