getRoomIdByAlias method
Requests that the server resolve a room alias to a room ID.
The server will use the federation API to resolve the alias if the domain part of the alias does not correspond to the server's own domain.
roomAlias
The room alias. Its format is defined
in the appendices.
Implementation
Future<GetRoomIdByAliasResponse> getRoomIdByAlias(String roomAlias) async {
final requestUri = Uri(
path:
'_matrix/client/v3/directory/room/${Uri.encodeComponent(roomAlias)}',
);
final request = Request('GET', baseUri!.resolveUri(requestUri));
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 GetRoomIdByAliasResponse.fromJson(json as Map<String, Object?>);
}