fetchPublicGroupsFromServer method

Future<EMCursorResult<EMGroupInfo>> fetchPublicGroupsFromServer({
  1. int pageSize = 200,
  2. String? cursor,
})

~english Gets public groups from the server with pagination.

Param pageSize The number of public groups per page.

Param cursor The cursor position from which to start to get data next time. Sets the parameter as null for the first time.

Return The result of EMCursorResult, including the cursor for getting data next time and the group list. If EMCursorResult.cursor is an empty string (""), all data is fetched.

Throws A description of the exception. See EMError. ~end

~chinese 以分页方式从服务器获取当前用户加入的所有公开群组。

Param pageSize 每页返回的群组数。

Param cursor 从这个游标位置开始取数据,首次获取数据时传 null,按照用户加入公开群组时间的顺序还是逆序获取数据。

Return 包含用于下次获取数据的 cursor 以及群组列表。返回的结果中,当 EMCursorResult.getCursor() 为空字符串 ("") 时,表示没有更多数据。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 EMError。 ~end

Implementation

Future<EMCursorResult<EMGroupInfo>> fetchPublicGroupsFromServer({
  int pageSize = 200,
  String? cursor,
}) async {
  Map req = {'pageSize': pageSize};
  req.putIfNotNull("cursor", cursor);
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.getPublicGroupsFromServer, req);
  try {
    EMError.hasErrorFromResult(result);
    return EMCursorResult<EMGroupInfo>.fromJson(
        result[ChatMethodKeys.getPublicGroupsFromServer],
        dataItemCallback: (value) {
      return EMGroupInfo.fromJson(value);
    });
  } on EMError catch (e) {
    throw e;
  }
}