fetchJoinedGroupsFromServer method
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.
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;
}
}