createChatRoom method Null safety

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

Creates a chat room.

Param subject The chat room subject.

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 {@link EMError}.

Implementation

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