getJoinedGroups method

Future<List<EMGroup>> getJoinedGroups()

~english Gets all group information of the current user from the local cache.

Returns The list of groups.

Throws Exception description, see EMError. ~end

~chinese 获取本地缓存中当前用户的所有群组信息。

Return 群组列表。

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

Implementation

Future<List<EMGroup>> getJoinedGroups() async {
  try {
    Map result = await Client.instance.groupManager
        .callNativeMethod(ChatMethodKeys.getJoinedGroups);
    EMError.hasErrorFromResult(result);
    List<EMGroup> list = [];
    result[ChatMethodKeys.getJoinedGroups]
        ?.forEach((element) => list.add(EMGroup.fromJson(element)));
    return list;
  } catch (e) {
    rethrow;
  }
}