fetchMemberListFromServer method

Future<EMCursorResult<String>> fetchMemberListFromServer(
  1. String groupId, {
  2. int pageSize = 200,
  3. String? cursor,
})

~english Gets the member list of the group with pagination.

For example:

  EMCursorResult<String> result = await EMClient.getInstance.groupManager.fetchMemberListFromServer(groupId); // search 1
  result = await EMClient.getInstance.groupManager.fetchMemberListFromServer(groupId, cursor: result.cursor); // search 2

Param groupId The group ID.

Param pageSize The number of group members 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 member list. If EMCursorResult.cursor is an empty string (""), all data is fetched.

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

~chinese 以分页方式获取群组成员列表。

例如:

  EMCursorResult<String> result = await EMClient.getInstance.groupManager.fetchMemberListFromServer(groupId); // search 1
  result = await EMClient.getInstance.groupManager.fetchMemberListFromServer(groupId, cursor: result.cursor); // search 2

Param groupId 群组 ID。

Param pageSize 每页返回的群组成员数。

Param cursor 从这个游标位置开始取数据,首次获取数据时传 null 即可。

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

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

Implementation

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