loadMessage method
- String messageId
Gets the message with a specific message ID.
If the message is already loaded into the memory cache, the message will be directly returned; otherwise, the message will be loaded from the local database and loaded in the memory.
Param messageId The message ID.
Return The message instance.
Throws A description of the exception. See ChatError.
Implementation
Future<ChatMessage?> loadMessage(String messageId) async {
try {
Map req = _toJson();
req['msgId'] = messageId;
Map result = await platform_interface.Client.instance.conversationManager
.callNativeMethod(ChatMethodKeys.loadMsgWithId, req);
ChatError.hasErrorFromResult(result);
if (result[ChatMethodKeys.loadMsgWithId] != null) {
return ChatMessage.fromJson(result[ChatMethodKeys.loadMsgWithId]);
} else {
return null;
}
} catch (e) {
rethrow;
}
}