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 {
Map req = this._toJson();
req['msg_id'] = messageId;
Map result = await _emConversationChannel.invokeMethod(
ChatMethodKeys.loadMsgWithId, req);
try {
ChatError.hasErrorFromResult(result);
if (result[ChatMethodKeys.loadMsgWithId] != null) {
return ChatMessage.fromJson(result[ChatMethodKeys.loadMsgWithId]);
} else {
return null;
}
} on ChatError catch (e) {
throw e;
}
}