如何用 ZLibEncoder 替换 ZLibDeflater

Fox*_*x32 2 dart dart-io

我正在使用 ZLibDeflater 压缩文件,方法是将其作为流读取并进行转换:

new File(filePath)
   .openRead()
   .transform(new ZLibDeflater())
   .pipe(new File(gzipPath).openWrite())
   .then(...);
Run Code Online (Sandbox Code Playgroud)

由于 ZLibDeflater现在已弃用,我该如何转换代码以使用新的GZipCodec类?

Ale*_*uin 5

您还可以使用ZLIB

new File(filePath)
  .openRead()
  .transform(ZLIB.decoder)
  .pipe(new File(zlibPath).openWrite())
  .then(...);
Run Code Online (Sandbox Code Playgroud)