lastReceivedMessage method

Future<ChatMessage?> lastReceivedMessage()

Gets the latest message from the conversation.

Return The message instance.

Implementation

Future<ChatMessage?> lastReceivedMessage() async {
  try {
    Map req = _toJson();
    Map result = await platform_interface.Client.instance.conversationManager
        .callNativeMethod(ChatMethodKeys.getLatestMessageFromOthers, req);
    ChatError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getLatestMessageFromOthers)) {
      return ChatMessage.fromJson(
          result[ChatMethodKeys.getLatestMessageFromOthers]);
    } else {
      return null;
    }
  } catch (e) {
    rethrow;
  }
}