decodeRevDocument function
Decodes rev once, for revDocumentPayloadSources and then revToRiv.
scriptLanguage and externalMappedIds as the export's request names
them. Null when the rev does not decode or markupAvailable is false.
Implementation
RevDocument? decodeRevDocument(
Uint8List rev, {
String scriptLanguage = '',
Map<String, int> externalMappedIds = const {},
}) {
if (!markupAvailable || rev.isEmpty) {
return null;
}
final options = encodeRevDocumentOptions(scriptLanguage, externalMappedIds);
final source = calloc<Uint8>(rev.length);
final optionSource = calloc<Uint8>(options.length);
try {
source.asTypedList(rev.length).setAll(0, rev);
optionSource.asTypedList(options.length).setAll(0, options);
final document = _revDocumentDecode(
source,
rev.length,
optionSource,
options.length,
);
return document == nullptr ? null : RevDocument(document.address);
} finally {
calloc.free(optionSource);
calloc.free(source);
}
}