fetchJoinedGroupsFromServer method

Future<List<ChatGroup>> fetchJoinedGroupsFromServer({
  1. int pageSize = 20,
  2. int pageNum = 0,
  3. bool needMemberCount = false,
  4. bool needRole = false,
})

~english Gets all groups of the current user from the server.

This method returns a group list which does not contain member information. If you want to update information of a group to include its member information, call fetchGroupInfoFromServer.

Param pageSize The size of groups per page.

Param pageNum The page number.

Param needMemberCount The return result contains the number of group members

Param needRole The result contains the current user's role in the group

Return The list of groups that the current user joins.

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

~chinese 从服务器中获取当前用户加入的所有群组。

此操作只返回群组列表,不包含所有成员的信息。如果要更新某个群组包括成员的全部信息,需要再调用 ChatGroupManager.fetchGroupInfoFromServer

Return 当前用户加入的群组的列表。

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

Implementation

Future<List<ChatGroup>> fetchJoinedGroupsFromServer({
  int pageSize = 20,
  int pageNum = 0,
  bool needMemberCount = false,
  bool needRole = false,
}) async {
  Map req = {
    'pageSize': pageSize,
    'pageNum': pageNum,
    "needMemberCount": needMemberCount,
    "needRole": needRole,
  };
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.getJoinedGroupsFromServer, req);
  try {
    ChatError.hasErrorFromResult(result);
    List<ChatGroup> list = [];
    result[ChatMethodKeys.getJoinedGroupsFromServer]
        ?.forEach((element) => list.add(ChatGroup.fromJson(element)));
    return list;
  } on ChatError catch (e) {
    throw e;
  }
}