getChatRoomWithId method Null safety
- 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.fetchChatRoomInfoFromServer)) {
return EMChatRoom.fromJson(
result[ChatMethodKeys.fetchChatRoomInfoFromServer]);
} else {
return null;
}
} on EMError catch (e) {
throw e;
}
}