decompressBytes function

Future<Uint8List> decompressBytes(
  1. Uint8List input
)

Decompresses a GZip compressed byte array into a byte array.

Implementation

Future<Uint8List> decompressBytes(Uint8List input) async {
  final blob = web.Blob([input.toJS].toJS);
  final response = web.Response(blob);

  final decompressionStream = DecompressionStream('gzip');
  final decompressedStream = response.body!.pipeThrough(decompressionStream);

  final decompressedResponse = web.Response(decompressedStream);
  final arrayBuffer = await decompressedResponse.arrayBuffer().toDart;
  return arrayBuffer.toDart.asUint8List();
}