fetchPublicChatRoomsFromServer method

Future<ChatPageResult<ChatRoom>> fetchPublicChatRoomsFromServer(
  1. {int pageNum = 1,
  2. int pageSize = 200}
)

Gets chat room data from the server with pagination.

Param pageNum The page number, starting from 1.

Param pageSize The number of records per page.

Return Chat room data. See ChatPageResult.

Throws A description of the exception. See ChatError.

Implementation

Future<ChatPageResult<ChatRoom>> fetchPublicChatRoomsFromServer({
  int pageNum = 1,
  int pageSize = 200,
}) async {
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.fetchPublicChatRoomsFromServer,
      {"pageNum": pageNum, "pageSize": pageSize});
  try {
    ChatError.hasErrorFromResult(result);
    return ChatPageResult<ChatRoom>.fromJson(
        result[ChatMethodKeys.fetchPublicChatRoomsFromServer],
        dataItemCallback: (map) {
      return ChatRoom.fromJson(map);
    });
  } on ChatError catch (e) {
    throw e;
  }
}