getGroupWithId method

Future<EMGroup?> getGroupWithId(
  1. String groupId
)

~english Gets the group instance from the cache by group ID.

Param groupId The group ID.

Return The group instance. Returns null if the group does not exist.

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

~chinese 根据群组 ID,从本地缓存中获取指定群组。

Param groupId 群组 ID。

Return 返回群组对象。如果群组不存在,返回 null。

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

Implementation

Future<EMGroup?> getGroupWithId(String groupId) async {
  Map req = {'groupId': groupId};
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getGroupWithId, req);
  try {
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getGroupWithId)) {
      return EMGroup.fromJson(result[ChatMethodKeys.getGroupWithId]);
    } else {
      return null;
    }
  } on EMError catch (e) {
    throw e;
  }
}