createGroup static method
Future<V2TimValueCallback<String>>
createGroup(
{ - String? groupID,
- required String groupType,
- required String groupName,
- String? notification,
- String? introduction,
- String? faceUrl,
- bool? isAllMuted,
- int? addOpt,
- List<V2TimGroupMember>? memberList,
- bool? isSupportTopic,
- int? approveOpt,
})
Implementation
static Future<V2TimValueCallback<String>> createGroup({
String? groupID,
required String groupType,
required String groupName,
String? notification,
String? introduction,
String? faceUrl,
bool? isAllMuted,
int? addOpt,
List<V2TimGroupMember>? memberList,
bool? isSupportTopic,
int? approveOpt,
}) async {
String param = json.encode({
"create_group_param_group_id": groupID,
"create_group_param_group_name": groupName,
"create_group_param_group_type": Tools.dart2cgroupType(groupType),
"create_group_param_is_support_topic": isSupportTopic,
"create_group_param_group_member_array": Tools.generateNativeMemberListByDartParam(memberList ?? []),
"create_group_param_add_option": addOpt,
"create_group_param_notification": notification,
"create_group_param_introduction": introduction,
"create_group_param_face_url": faceUrl,
"create_group_param_approve_option": approveOpt,
});
Pointer<Uint8> json_group_create_param = Tools.string2PointerInt8(param);
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
int res = desktopSDK.D_TIMGroupCreate(json_group_create_param, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimValueCallback<String>.fromJson({
"code": res,
"desc": "",
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
// 创建成功后,这里通过设置群资料单独设置全员禁言 TODO
if (isAllMuted != null) {}
String sp = data["json_param"] ?? json.encode({});
String gid = (json.decode(sp.isEmpty ? json.encode({}) : sp))["create_group_result_groupid"] ?? "";
return V2TimValueCallback<String>.fromJson({
"code": data["code"],
"desc": data["desc"],
"data": gid,
});
}
}