read method

List read()

Implementation

List read() {
  if (val.length < bytelen) {
    throw Exception('Not enough bytes!');
  }

  // Convert the relevant bytes to a hexadecimal string
  String hexString = val
      .sublist(0, bytelen)
      .map((byte) => byte.toRadixString(16).padLeft(2, '0'))
      .join();

  // Parse the hexadecimal string as an integer
  int number = int.parse(hexString, radix: 16);

  // Return the parsed number and the remaining buffer
  return [number, val.sublist(bytelen)];
}