extractFile static method

Future<void> extractFile(
  1. File file,
  2. String destinationPath
)

Implementation

static Future<void> extractFile(File file, String destinationPath) async {
  var bytes = await file.readAsBytes();
  var archive = ZipDecoder().decodeBytes(bytes);
  for (var file in archive) {
    var filename = file.name;
    if (file.isFile) {
      var data = file.content as List<int>;
      File('$destinationPath/$filename')
        ..createSync(recursive: true)
        ..writeAsBytesSync(data);
    } else {
      Directory('$destinationPath/$filename').create(recursive: true);
    }
  }
}