createChannel static method

Future<GroupChannel> createChannel(
  1. GroupChannelCreateParams params,
  2. {ProgressHandler? progressHandler,
  3. Chat? chat}
)

Creates GroupChannel with GroupChannelCreateParams.

#################### 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 ####################

Implementation

static Future<GroupChannel> createChannel(
  GroupChannelCreateParams params, {
  ProgressHandler? progressHandler,
  Chat? chat,
}) async {
  sbLog.i(StackTrace.current, 'params.userIds: ${params.userIds}');
  chat ??= SendbirdChat().chat;

  final currentUserId = chat.chatContext.currentUserId ?? '';
  if (params.userIds?.isEmpty ?? true) {
    params.userIds = [currentUserId];
  } else if (params.userIds?.contains(currentUserId) == false) {
    params.userIds?.add(currentUserId);
  }

  return await chat.apiClient.send<GroupChannel>(GroupChannelCreateRequest(
    chat,
    params,
    progressHandler: progressHandler,
  ));
}