fetchConversationListFromServer method
- @Deprecated('Use [fetchConversationsByOptions] instead')
~english Gets the list of 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. ~end
~chinese 获取服务器会话列表。
Param pageNum
当前页码。
Param pageSize
每页期望返回的会话数量。
Return 当前用户的会话列表。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end
Implementation
@Deprecated('Use [fetchConversationsByOptions] instead')
/// ~english
/// Gets the list of 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].
/// ~end
///
/// ~chinese
/// 获取服务器会话列表。
///
/// Param [pageNum] 当前页码。
///
/// Param [pageSize] 每页期望返回的会话数量。
///
/// **Return** 当前用户的会话列表。
///
/// **Throws** 如果有异常会在这里抛出,包含错误码和错误描述,详见 [ChatError]。
/// ~end
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;
}
}