modifyMessage method

Future<ChatMessage> modifyMessage(
  1. {required String messageId,
  2. required ChatTextMessageBody msgBody}
)

Modifies a message.

After this method is called to modify a message, both the local message and the message on the server are modified.

This method can only modify a text message in one-to-one chats or group chats, but not in chat rooms.

Param messageId The ID of the message to modify.

Param msgBody The modified message body ChatTextMessageBody.

Return The modified message.

Throws A description of the exception. See ChatError.

Implementation

Future<ChatMessage> modifyMessage({
  required String messageId,
  required ChatTextMessageBody msgBody,
}) async {
  Map map = {
    'msgId': messageId,
    'body': msgBody.toJson(),
  };

  Map result = await ChatChannel.invokeMethod(
    ChatMethodKeys.modifyMessage,
    map,
  );
  try {
    ChatError.hasErrorFromResult(result);
    return ChatMessage.fromJson(result[ChatMethodKeys.modifyMessage]);
  } on ChatError catch (e) {
    throw e;
  }
}