loadAllConversations method
~english 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 ChatError. ~end
~chinese 获取本地数据库中所有会话。
会先从内存中获取,如果没有会从本地数据库获取。
Return 返回获取的会话。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end
Implementation
Future<List<ChatConversation>> loadAllConversations() async {
Map result =
await ChatChannel.invokeMethod(ChatMethodKeys.loadAllConversations);
try {
ChatError.hasErrorFromResult(result);
List<ChatConversation> conversationList = [];
result[ChatMethodKeys.loadAllConversations]?.forEach((element) {
conversationList.add(ChatConversation.fromJson(element));
});
return conversationList;
} on ChatError catch (e) {
throw e;
}
}