writeVariableEncInt method

dynamic writeVariableEncInt(
  1. int value
)

Implementation

writeVariableEncInt(int value) {
  if (value < 251) {
    writeUint8(value);
  } else if (value >= 251 && value < 65536) {
    writeUint8(0xfc);
    writeInt16(value);
  } else if (value >= 65536 && value < 16777216) {
    writeUint8(0xfd);
    final bd = ByteData(4);
    bd.setInt32(0, value, Endian.little);
    write(bd.buffer.asUint8List().sublist(0, 3));
  } else if (value >= 16777216) {
    writeUint8(0xfe);
    writeInt64(value);
  }
}