/// static
await ZipReader.extractAllToDirectory(
path,
Directory('miniz-3.1.2'),
onProgress: (stat, progress) {
print(
'progress: ${(progress * 100).toStringAsFixed(1)}% - ${stat.filename}',
);
},
);
// single
final path = '/home/thancoder/Downloads/miniz-3.1.2.zip';
final reader = ZipReader();
final res = reader.open(path);
if (res.isErr) {
print('Error: ${res.unwrapError()}');
return;
}
for (var f in reader.list) {
print(f);
print('comp size: ${f.compSizeLabel}');
print('size: ${f.uncompSizeLabel}');
await f.extractTo(
f.filename,
onProgress: (progress) {
print('progress: ${(progress * 100).toStringAsFixed(2)}%');
},
);
File(f.filename).writeAsBytesSync(f.readBytes);
}
// free memory
reader.close();