getChatRoomWithId method

Future<ChatRoom?> 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 ChatError. ~end

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

Param roomId 聊天室 ID。

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

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

Implementation

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