ungzip function
Inflates a GZIP-ed list of bytes back to the original list of bytes.
Implementation
List<int> ungzip(List<int> bytes) {
final output = <int>[];
Object? error;
final controller = StreamController<List<int>>(sync: true);
controller.stream
.transform(ZLibDecoder())
.listen((data) => output.addAll(data),
onError: (e) => error = e);
controller.add(bytes);
controller.close();
if (error != null) throw error!;
return output; //note: it is done synchronously
}