getGroupWithId method
- 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 ChatError. ~end
~chinese 根据群组 ID,从本地缓存中获取指定群组。
Param groupId
群组 ID。
Return 返回群组对象。如果群组不存在,返回 null。
Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~end
Implementation
Future<ChatGroup?> getGroupWithId(String groupId) async {
Map req = {'groupId': groupId};
Map result =
await _channel.invokeMethod(ChatMethodKeys.getGroupWithId, req);
try {
ChatError.hasErrorFromResult(result);
if (result.containsKey(ChatMethodKeys.getGroupWithId)) {
return ChatGroup.fromJson(result[ChatMethodKeys.getGroupWithId]);
} else {
return null;
}
} on ChatError catch (e) {
throw e;
}
}