getChatRoomWithId method

Future<EMChatRoom?> getChatRoomWithId(
  1. String roomId
)

~english Gets the chat room in the cache.

Param roomId The chat room ID.

Return The chat room instance. Returns null if the chat room is not found in the cache.

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

~chinese 从内存中获取聊天室。

Param roomId 聊天室 ID。

Return 返回聊天室对象。如果内存中不存在聊天室对象,返回 null。

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

Implementation

Future<EMChatRoom?> getChatRoomWithId(String roomId) async {
  Map result = await _channel
      .invokeMethod(ChatMethodKeys.getChatRoom, {"roomId": roomId});
  try {
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getChatRoom)) {
      return EMChatRoom.fromJson(result[ChatMethodKeys.getChatRoom]);
    } else {
      return null;
    }
  } on EMError catch (e) {
    throw e;
  }
}