replyMessage method

Future<Map> replyMessage(
  1. dynamic message,
  2. dynamic replyMessage,
  3. dynamic config,
  4. int progressID,
  5. int messageAttachedCallbackID,
)

Implementation

Future<Map<dynamic, dynamic>> replyMessage(
    dynamic message,
    dynamic replyMessage,
    dynamic config,
    int progressID,
    int messageAttachedCallbackID) async {
  Map notification = {
    'onMessageAttached':
        allowInterop((message, currentFileSize, totalFileSize) {
      ZIMMessageAttachedCallback? callback = ZIMCommonData
          .zimMessageAttachedCallbackMap[messageAttachedCallbackID];

      if (callback != null) {
        ZIMMessage zimMessage = getZIMMessage(message);
        callback(zimMessage);
      }
    }),
    'onMediaUploadingProgress':
        allowInterop((message, currentFileSize, totalFileSize) {
      ZIMMediaDownloadingProgress? progress =
          ZIMCommonData.mediaDownloadingProgressMap[progressID];

      if (progress != null) {
        ZIMMessage zimMessage = getZIMMessage(message);
        progress(zimMessage, currentFileSize, totalFileSize);
      }
    })
  };

  final result = await promiseToFuture(ZIM.getInstance()!.replyMessage(
          mapToJSObj(message),
          mapToJSObj(replyMessage),
          mapToJSObj(config),
          mapToJSObj(notification)))
      .catchError((e) {
    throw PlatformException(code: e.code.toString(), message: e.message);
  });

  return jsObjectToMap(result);
}