unzipFile static method

Future<bool> unzipFile(
  1. String zipFilePath,
  2. String destinationDir
)

解压zip文件到指定目录

可能抛出 PlatformException 当原生平台调用失败时 可能抛出 ArgumentError 当参数无效时

Implementation

static Future<bool> unzipFile(String zipFilePath, String destinationDir) async {
  try {
    final result = await _channel.invokeMethod<bool>(
      'unzipFile',
      {
        'zipFilePath': zipFilePath,
        'destinationDir': destinationDir,
      },
    );
    return result ?? false;
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: '解压文件失败: ${e.message}',
      details: e.details,
    );
  } catch (e) {
    throw Exception('解压文件时发生未知错误: $e');
  }
}