encode method Null safety

List<int> encode(
  1. Archive archive,
  2. {OutputStreamBase? output}
)

Implementation

List<int> encode(Archive archive, {OutputStreamBase? output}) {
  final outputStream = output ?? OutputStream();
  start(outputStream);

  for (final file in archive.files) {
    add(file);
  }

  finish();

  if (outputStream is OutputStream) {
    return outputStream.getBytes();
  }
  return [];
}