loadMessage method

Future<ChatMessage?> loadMessage(
  1. String messageId
)

Loads a message from the local database by message ID.

Param messageId The message ID.

Return The message object specified by the message ID. Returns null if the message does not exist.

Throws A description of the exception. See ChatError.

Implementation

Future<ChatMessage?> loadMessage(String messageId) async {
  Map req = {"msg_id": messageId};
  Map<String, dynamic> result =
      await ChatChannel.invokeMethod(ChatMethodKeys.getMessage, req);
  try {
    ChatError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getMessage)) {
      return ChatMessage.fromJson(result[ChatMethodKeys.getMessage]);
    } else {
      return null;
    }
  } on ChatError catch (e) {
    throw e;
  }
}