getRoomState method

Future<List<SDNEvent>> getRoomState(
  1. String roomId
)
inherited

Get the state events for the current state of a room.

roomId The room to look up the state for.

Implementation

Future<List<SDNEvent>> getRoomState(String roomId) async {
  final requestUri =
      Uri(path: '_api/client/v3/rooms/${Uri.encodeComponent(roomId)}/state');
  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 (json as List)
      .map((v) => SDNEvent.fromJson(v as Map<String, Object?>))
      .toList();
}