fetchJoinedGroupsFromServer method

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

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

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

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

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

Implementation

Future<List<EMGroup>> 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 {
    EMError.hasErrorFromResult(result);
    List<EMGroup> list = [];
    result[ChatMethodKeys.getJoinedGroupsFromServer]
        ?.forEach((element) => list.add(EMGroup.fromJson(element)));
    return list;
  } on EMError catch (e) {
    throw e;
  }
}