createChannel static method Null safety
- GroupChannelParams params,
- {OnUploadProgressCallback? progress}
#################### SECURITY TIPS ####################
Before launching, you should review "Allow creating group channels from SDK" under ⚙️ Sendbird Dashboard -> Settings -> Security.
It's turned on at first to simplify running samples and implementing your first code.
Most apps will want to disable "Allow creating group channels from SDK" as that could cause unwanted operations.
#################### SECURITY TIPS ####################
Creates a channel with given params
.
After this method completes successfully, channel event such as
ChannelEventHandler.onUserJoined,
ChannelEventHandler.onUserReceivedInvitation and/or
ChannelEventHandler.onChannelOperatorsUpdated can be invoked based
on the given params
.
Implementation
/// Creates a channel with given [params].
///
/// After this method completes successfully, channel event such as
/// [ChannelEventHandler.onUserJoined],
/// [ChannelEventHandler.onUserReceivedInvitation] and/or
/// [ChannelEventHandler.onChannelOperatorsUpdated] can be invoked based
/// on the given [params].
static Future<GroupChannel> createChannel(
GroupChannelParams params, {
OnUploadProgressCallback? progress,
}) async {
final sdk = SendbirdSdk().getInternal();
final currentUserId = sdk.state.userId ?? '';
if (params.userIds?.isEmpty ?? true) {
params.userIds = [currentUserId];
} else if (params.userIds?.contains(currentUserId) == false) {
params.userIds?.add(currentUserId);
}
return sdk.api.send<GroupChannel>(
GroupChannelCreateRequest(params, onProgress: progress));
}