zipDirectoryAsync method

Future<void> zipDirectoryAsync(
  1. Directory dir, {
  2. String? filename,
  3. int? level,
  4. bool followLinks = true,
  5. void onProgress(
    1. double
    )?,
  6. DateTime? modified,
})

Zips a dir to a Zip file asynchronously.

filename determines where the Zip file will be created. If filename is not specified, the name of the directory will be used with a '.zip' extension. If filename is within dir, it will throw a FormatException.

See also:

  • zipDirectory for the synchronous version of this method.
  • _composeZipDirectoryPath for the logic of composing the Zip file path.

Implementation

Future<void> zipDirectoryAsync(Directory dir,
    {String? filename,
    int? level,
    bool followLinks = true,
    void Function(double)? onProgress,
    DateTime? modified}) async {
  create(
    _composeZipDirectoryPath(dir: dir, filename: filename),
    level: level ??= GZIP,
    modified: modified,
  );

  await addDirectory(dir,
      includeDirName: false,
      level: level,
      followLinks: followLinks,
      onProgress: onProgress);
  closeSync();
}