createChatRoom method

Future<ChatRoom> createChatRoom(
  1. String name, {
  2. String? desc,
  3. String? welcomeMsg,
  4. int maxUserCount = 300,
  5. List<String>? members,
})

~english Creates a chat room.

Param name The chat room name.

Param desc The chat room description.

Param welcomeMsg A welcome message that invites users to join the chat room.

Param maxUserCount The maximum number of members allowed to join the chat room.

Param members The list of members invited to join the chat room.

Return The chat room instance.

Throws A description of the exception. See ChatError. ~end

~chinese 创建聊天室。

Param name 聊天室名称。

Param desc 聊天室描述。

Param welcomeMsg 邀请成员加入聊天室的消息。

Param maxUserCount 允许加入聊天室的最大成员数。

Param members 邀请加入聊天室的成员列表。

Return 创建成功的聊天室对象。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end

Implementation

Future<ChatRoom> createChatRoom(
  String name, {
  String? desc,
  String? welcomeMsg,
  int maxUserCount = 300,
  List<String>? members,
}) async {
  Map req = Map();
  req['subject'] = name;
  req['maxUserCount'] = maxUserCount;
  req.putIfNotNull("desc", desc);
  req.putIfNotNull("welcomeMsg", welcomeMsg);
  req.putIfNotNull("members", members);
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.createChatRoom, req);
  try {
    ChatError.hasErrorFromResult(result);
    return ChatRoom.fromJson(result[ChatMethodKeys.createChatRoom]);
  } on ChatError catch (e) {
    throw e;
  }
}