createGroup method Null safety
Creates a group instance.
After the group is created, the data in the cache and database will be updated and multiple devices will receive the notification event and update the group data to the cache and database. You can set {@link com.ChatMultiDeviceListener} to listen for the event. If an event occurs, the callback function {@link ChatMultiDeviceListener#onGroupEvent(int, String, List)} is triggered, where the first parameter is the event which is {@link ChatContactGroupEvent#GROUP_CREATE} for a group creation event.
Param groupName The group name.
Param desc The group description.
Param inviteMembers The group member array. The group owner ID is optional.
Param inviteReason The group joining invitation.
Param options The options for creating a group. See {@link ChatGroupOptions}.
The options are as follows:
- The maximum number of group members. The default value is 200.
- The group style. See {@link ChatGroupManager.ChatGroupStyle}. The default value is {@link ChatGroupStyle#PrivateOnlyOwnerInvite}.
- Whether to ask for permission when inviting a user to join the group. The default value is
false, indicating that invitees are automatically added to the group without their permission. - The group detail extensions.
Return The created group instance.
Throws A description of the exception. See {@link ChatError}.
Implementation
Future<ChatGroup> createGroup({
String? groupName,
String? desc,
List<String>? inviteMembers,
String? inviteReason,
required ChatGroupOptions options,
}) async {
Map req = {'options': options.toJson()};
req.setValueWithOutNull("groupName", groupName);
req.setValueWithOutNull("desc", desc);
req.setValueWithOutNull("inviteMembers", inviteMembers);
req.setValueWithOutNull("inviteReason", inviteReason);
Map result = await _channel.invokeMethod(ChatMethodKeys.createGroup, req);
try {
ChatError.hasErrorFromResult(result);
return ChatGroup.fromJson(result[ChatMethodKeys.createGroup]);
} on ChatError catch (e) {
throw e;
}
}