modifyMessage method
- required String messageId,
- ChatMessageBody? msgBody,
- Map<
String, dynamic> ? attributes,
修改消息内容。
调用该方法修改消息内容后,本地和服务端的消息均会修改。
只能调用该方法修改单聊和群聊中的文本消息,不能修改聊天室消息。
Param messageId 消息实例 ID。
Param msgBody 息体实例 ChatMessageBody, 只支持 ChatTextMessageBody, ChatCustomMessageBody。
Param attributes 消息的扩展字段
Return 修改后的消息实例。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。
Implementation
Future<ChatMessage> modifyMessage({
required String messageId,
ChatMessageBody? msgBody,
Map<String, dynamic>? attributes,
}) async {
try {
Map map = {'msgId': messageId};
map.putIfNotNull('msgBody', msgBody?.toJson());
map.putIfNotNull('attributes', attributes);
Map result = await platform_interface.Client.instance.chatManager.callNativeMethod(
ChatMethodKeys.modifyMessage,
map,
);
ChatError.hasErrorFromResult(result);
return ChatMessage.fromJson(result[ChatMethodKeys.modifyMessage]);
} catch (e) {
rethrow;
}
}