getOneRoomEvent method
Get a single event based on roomId/eventId
. You must have permission to
retrieve this event e.g. by being a member in the room for this event.
roomId
The ID of the room the event is in.
eventId
The event ID to get.
Implementation
Future<MatrixEvent> getOneRoomEvent(String roomId, String eventId) async {
final requestUri = Uri(
path:
'_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/event/${Uri.encodeComponent(eventId)}',
);
final request = Request('GET', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return MatrixEvent.fromJson(json as Map<String, Object?>);
}