ZipUtil class

压缩解压工具类

使用示例:

// 压缩(无密码)
try {
  final zipPath = await ZipUtil.zip(
    '/your/source/folder_or_file',
    '/your/target/output.zip',
  );
  print('压缩成功:$zipPath');
} catch (e) {
  print('压缩失败:$e');
}

// 压缩(有密码)
try {
  final zipPath = await ZipUtil.zipWithPassword(
    '/your/source/folder_or_file',
    '/your/target/encrypted.zip',
    '123456',
  );
  print('加密压缩成功:$zipPath');
} catch (e) {
  print('加密压缩失败:$e');
}

// 解压(无密码)
try {
  final files = await ZipUtil.unzip(
    '/your/source/output.zip',
    '/your/target/dir',
  );
  print('解压成功,文件列表:$files');
} catch (e) {
  print('解压失败:$e');
}

// 解压(有密码)
try {
  final files = await ZipUtil.unzipWithPassword(
    '/your/source/encrypted.zip',
    '/your/target/dir',
    '123456',
  );
  print('解密解压成功,文件列表:$files');
} catch (e) {
  print('解密解压失败:$e');
}

Constructors

ZipUtil()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

unzip(String zipPath, String targetPath) Future<List<String>>
解压zip文件到目标路径(不加密/无密码zip)
unzipWithPassword(String zipPath, String targetPath, String password) Future<List<String>>
解压加密zip文件到目标路径
zip(String sourcePath, String targetPath) Future<String>
压缩文件/文件夹为zip包(不加密)
zipWithPassword(String sourcePath, String targetPath, String password) Future<String>
使用密码压缩文件/文件夹为 zip 包