decode method

  1. @override
DecodingResult<Uint8List> decode(
  1. ByteBuffer buffer,
  2. int offset
)
override

Implementation

@override
DecodingResult<Uint8List> decode(ByteBuffer buffer, int offset) {
  final lengthResult = const UintType().decode(buffer, offset);
  final length = lengthResult.data.toInt();
  final padding = calculatePadLength(length, allowEmpty: true);

  // first 32 bytes are taken for the encoded size, read from there
  return DecodingResult(
    buffer.asUint8List(offset + sizeUnitBytes, length),
    sizeUnitBytes + length + padding,
  );
}