tryDecryptAttachment method

Future<Uint8List?> tryDecryptAttachment(
  1. String sdkId,
  2. Document document,
  3. Uint8List encryptedAttachment,
  4. bool decryptedAttachmentValidator(
    1. Uint8List
    )?,
)

Implementation

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