gzip function
Deflates a list of bytes with GZIP.
Implementation
List<int> gzip(List<int> bytes, {int level = 6}) {
final output = <int>[];
Object? error;
final controller = StreamController<List<int>>(sync: true);
controller.stream
.transform(ZLibEncoder(level: level))
.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
}