saveAsZip function

void saveAsZip(
  1. Map<String, String> files,
  2. String path
)

Saves or downloads(depending on platform) the project as a zip archive. Accepts a file Map(filename-content), most likely from getAllFiles, and a path to save to(must include filename + .zip extension)

Implementation

void saveAsZip(Map<String, String> files, String path) {
  var stopwatch = Stopwatch()..start();
  final bytes = ZipEncoder().encode(getArchive(files));
  if (bytes != null) {
    io.saveBytes(bytes, path).then((v) {
      print(
        'Finished saving the Zip file $path in: ${stopwatch.elapsedMilliseconds}ms',
      );
      stopwatch.stop();
    });
  } else {
    throw 'something went wrong zipping your datapack';
  }
}