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