decode method

  1. @override
Uint8List decode(
  1. Uint8List input,
  2. int expectedRawLength
)
override

Decompresses input back to expectedRawLength bytes.

Implementation

@override
Uint8List decode(Uint8List input, int expectedRawLength) {
  RangeError.checkNotNegative(expectedRawLength, 'expectedRawLength');
  final sink = _BoundedBytesSink(expectedRawLength);
  try {
    _decoder.startChunkedConversion(sink)
      ..add(input)
      ..close();
  } on WalPackCodecException {
    rethrow;
  } on Object catch (error) {
    throw WalPackCodecException('ZLib decode failed', error);
  }
  if (sink.offset != expectedRawLength) {
    throw WalPackCodecException(
      'ZLib decoded length mismatch: got ${sink.offset}, '
      'expected $expectedRawLength',
    );
  }
  return sink.buffer;
}