fetchConversationListFromServer method Null safety
fetch the conversations from the server.
Param pageNum The current page number.
Param pageSize The number of conversations to get on each page.
Return The conversation list of the current user.
Throws A description of the exception. See ChatError.
Implementation
Future<List<ChatConversation>> fetchConversationListFromServer({
int pageNum = 1,
int pageSize = 20,
}) async {
Map request = {
"pageNum": pageNum,
"pageSize": pageSize,
};
Map result = await ChatChannel.invokeMethod(
ChatMethodKeys.fetchConversationsFromServerWithPage,
request,
);
try {
ChatError.hasErrorFromResult(result);
List<ChatConversation> conversationList = [];
result[ChatMethodKeys.fetchConversationsFromServerWithPage]
?.forEach((element) {
conversationList.add(ChatConversation.fromJson(element));
});
return conversationList;
} on ChatError catch (e) {
throw e;
}
}