getRoomState method
Get the state events for the current state of a room.
roomId
The room to look up the state for.
Implementation
Future<List<MatrixEvent>> getRoomState(String roomId) async {
final requestUri = Uri(
path: '_matrix/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) => MatrixEvent.fromJson(v as Map<String, Object?>))
.toList();
}