latestMessage method

Future<ChatMessage?> latestMessage()

Gets the last message from the conversation.

The operation does not change the unread message count.

The SDK gets the latest message from the local memory first. If no message is found, the SDK loads the message from the local database and then puts it in the memory.

Return The message instance.


Future<ChatMessage?> latestMessage() async {
  Map req = this._toJson();
  Map result = await _emConversationChannel.invokeMethod(
      ChatMethodKeys.getLatestMessage, req);
  try {
    if (result.containsKey(ChatMethodKeys.getLatestMessage)) {
      return ChatMessage.fromJson(result[ChatMethodKeys.getLatestMessage]);
    } else {
      return null;
  } on ChatError catch (e) {
    throw e;