getGroupWithId method
- String groupId
~english Gets the group instance, creates it if it does not exist.
Param groupId The group ID.
Returns The group instance.
Throws Exception description, see EMError. ~end
~chinese 获取群组实例,如果不存在则创建。
Param groupId 群组 ID。
Return 群组实例。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError. ~end
Implementation
Future<EMGroup?> getGroupWithId(String groupId) async {
try {
Map req = {'groupId': groupId};
Map result = await Client.instance.groupManager
.callNativeMethod(ChatMethodKeys.getGroupWithId, req);
EMError.hasErrorFromResult(result);
if (result.containsKey(ChatMethodKeys.getGroupWithId)) {
return EMGroup.fromJson(result[ChatMethodKeys.getGroupWithId]);
} else {
return null;
}
} catch (e) {
rethrow;
}
}