getAndDecryptSecondaryAttachment method
Implementation
Future<Uint8List> getAndDecryptSecondaryAttachment(String sdkId, Document document, String key, bool Function(Uint8List)? decryptedAttachmentValidator) async {
final decryptedAttachmentValidatorCallbackId = decryptedAttachmentValidator != null ? CallbackReferences.create((data) async {
final x0 = base64Decode(data["x0"] as String);
final res = decryptedAttachmentValidator(x0);
return jsonEncode(res);
}) : null;
try {
final res = await _methodChannel.invokeMethod<String>(
'DocumentApi.getAndDecryptSecondaryAttachment',
{
"sdkId": sdkId,
"document": jsonEncode(Document.encode(document)),
"key": jsonEncode(key),
"decryptedAttachmentValidator": jsonEncode(decryptedAttachmentValidatorCallbackId),
}
).catchError(convertPlatformException);
if (res == null) throw AssertionError("received null result from platform method getAndDecryptSecondaryAttachment");
final parsedResJson = jsonDecode(res);
return base64Decode(parsedResJson as String);
} finally {
if (decryptedAttachmentValidatorCallbackId != null) CallbackReferences.delete(decryptedAttachmentValidatorCallbackId);
}
}