createChatRoom method

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

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.

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;
  }
}