getChatRoomWithId method Null safety

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

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

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