content property

  1. @override
List<int> content

Get the decompressed content from the file. The file isn't decompressed until it is requested.

Implementation

@override
List<int> get content {
  if (_content == null) {
    if (_encryptionType != encryptionNone) {
      if (_rawContent.length <= 0) {
        _content = _rawContent.toUint8List();
        _encryptionType = encryptionNone;
      } else {
        if (_encryptionType == encryptionZipCrypto) {
          _rawContent = _decodeZipCrypto(_rawContent);
        } else if (_encryptionType == encryptionAes) {
          _rawContent = _decodeAes(_rawContent);
        }
        _encryptionType = encryptionNone;
      }
    }

    if (compressionMethod == zipCompressionDeflate) {
      const oneGB = 1024 * 1024 * 1024;
      if (_rawContent is InputStream ||
          (useNativeZLib() && _rawContent.length < oneGB)) {
        _content = inflateBuffer(_rawContent.toUint8List());
      } else {
        _content = Inflate.buffer(_rawContent, uncompressedSize).getBytes();
      }
      compressionMethod = zipCompressionStore;
    } else if (compressionMethod == zipCompressionBZip2) {
      final output = OutputStream();
      BZip2Decoder().decodeStream(_rawContent, output);
      _content = output.getBytes();
      compressionMethod = zipCompressionStore;
    } else if (compressionMethod == zipCompressionStore) {
      _content = _rawContent.toUint8List();
    } else {
      throw ArchiveException(
          'Unsupported zip compression method $compressionMethod');
    }
  }

  return _content!;
}