read method
asset's content, decoded when it is stored encoded.
Throws UnsupportedError for an encoding this process cannot decode.
Implementation
Uint8List read(DVPackedAsset asset) {
final Uint8List stored = readStored(asset);
if (asset.encoding == DVAssetEncoding.identity) return stored;
final DVAssetDecoder? decode = DVAssetCodecs.decoder(asset.encoding);
if (decode == null) {
throw UnsupportedError(
'${asset.path} is stored as ${asset.encoding.token} and this process '
'has no ${asset.encoding.token} decoder');
}
final Uint8List decoded = decode(stored, asset.size);
if (decoded.length != asset.size) {
throw FormatException('${asset.path} decoded to ${decoded.length} bytes, '
'not the ${asset.size} it was packed as');
}
return decoded;
}