loadAllConversations method Null safety

Future<List<EMConversation>> loadAllConversations()

Gets all conversations from the local database.

Conversations will be first loaded from the cache. If no conversation is found, the SDK loads from the local database.

Return All the conversations from the cache or local database.

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

Implementation

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