getConversationsFromServer method Null safety

Future<List<EMConversation>> getConversationsFromServer()

Gets the conversation list from the server.

To use this function, you need to contact our business manager to activate it. After this function is activated, users can pull 10 conversations within 7 days by default (each convesation contains the latest historical message). If you want to adjust the number of conversations or time limit, please contact our business manager.

Return The conversation list of the current user.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<List<EMConversation>> getConversationsFromServer() async {
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getConversationsFromServer);
  try {
    EMError.hasErrorFromResult(result);
    List<EMConversation> conversationList = [];
    result[ChatMethodKeys.getConversationsFromServer]?.forEach((element) {
      conversationList.add(EMConversation.fromJson(element));
    });
    return conversationList;
  } on EMError catch (e) {
    throw e;
  }
}