decodeDataBlob function
Decode a Remote Flutter Widgets binary data blob.
This data is usually used in conjunction with DynamicContent.
This method supports a subset of the format supported by decodeLibraryBlob; specifically, it reads a value from that format (rather than a library), and disallows values other than maps, lists, ints, doubles, booleans, and strings. See decodeLibraryBlob for a description of the format.
The first four bytes of the file (in hex) are FE 52 57 44; see dataBlobSignature.
See also:
- encodeDataBlob, which encodes this format.
- decodeLibraryBlob, which uses a superset of this format to decode Remote Flutter Widgets binary library blobs.
- parseDataFile, which parses the text variant of this format.
Implementation
Object decodeDataBlob(Uint8List bytes) {
final _BlobDecoder decoder = _BlobDecoder(bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes));
decoder.expectSignature(dataBlobSignature);
final Object result = decoder.readValue();
if (!decoder.finished) {
throw const FormatException('Unexpected trailing bytes after value.');
}
return result;
}