encode method Null safety

List<int>? encode(
  1. Archive archive,
  2. {int level = Deflate.BEST_SPEED,
  3. OutputStreamBase? output,
  4. DateTime? modified}
)

Implementation

List<int>? encode(Archive archive,
    {int level = Deflate.BEST_SPEED,
    OutputStreamBase? output,
    DateTime? modified}) {
  output ??= OutputStream();

  startEncode(output, level: level, modified: modified);
  for (final file in archive.files) {
    addFile(file);
  }
  endEncode(comment: archive.comment);

  if (output is OutputStream) {
    return output.getBytes();
  }

  return null;
}