fetchGroupMembersInfo method

Future<EMCursorResult<GroupMemberInfo>> fetchGroupMembersInfo({
  1. required String groupId,
  2. String? cursor,
  3. int limit = 20,
})

~english Gets the list of group members from the server.

Param groupId The group ID. Param cursor The pagination cursor. Pass null for the first call. Param limit The maximum number of members to fetch per page.

Returns EMCursorResult containing group member list and next page cursor.

Throws Exception description, see EMError. ~end

~chinese 获取群组成员列表。

Param groupId 群组 ID。 Param cursor 分页游标,首次调用传空,下次使用上次返回的游标。 Param limit 每页获取的成员数量,默认 20 条。

Return 包含群成员信息列表和下一页游标的分页结果。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end

Implementation

Future<EMCursorResult<GroupMemberInfo>> fetchGroupMembersInfo({
  required String groupId,
  String? cursor,
  int limit = 20,
}) async {
  try {
    Map req = {
      "groupId": groupId,
      "limit": limit,
    };

    req.putIfNotNull('cursor', cursor);

    Map result = await Client.instance.groupManager.callNativeMethod(
      ChatMethodKeys.fetchGroupMembersInfo,
      req,
    );
    EMError.hasErrorFromResult(result);
    return EMCursorResult<GroupMemberInfo>.fromJson(
        result[ChatMethodKeys.fetchGroupMembersInfo],
        dataItemCallback: (value) {
      return GroupMemberInfo.fromJson(value);
    });
  } catch (e) {
    rethrow;
  }
}