addFile method Null safety

Future<void> addFile(
  1. File file,
  2. [String? filename,
  3. int? level = GZIP]
)

Implementation

Future<void> addFile(File file, [String? filename, int? level = GZIP]) async {
  var fileStream = InputFileStream(file.path);
  var archiveFile = ArchiveFile.stream(
      filename ?? path.basename(file.path), file.lengthSync(), fileStream);

  if (level == STORE) {
    archiveFile.compress = false;
  }

  archiveFile.lastModTime = file.lastModifiedSync()
      .millisecondsSinceEpoch ~/ 1000;
  archiveFile.mode = file.statSync().mode;

  _encoder.addFile(archiveFile);
  await fileStream.close();
}