getAndDecryptMainAttachment method
Implementation
Future<Uint8List> getAndDecryptMainAttachment(String sdkId, Document document, 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.getAndDecryptMainAttachment',
{
"sdkId": sdkId,
"document": jsonEncode(Document.encode(document)),
"decryptedAttachmentValidator": jsonEncode(decryptedAttachmentValidatorCallbackId),
}
).catchError(convertPlatformException);
if (res == null) throw AssertionError("received null result from platform method getAndDecryptMainAttachment");
final parsedResJson = jsonDecode(res);
return base64Decode(parsedResJson as String);
} finally {
if (decryptedAttachmentValidatorCallbackId != null) CallbackReferences.delete(decryptedAttachmentValidatorCallbackId);
}
}