queryLocationByAlias method

Future<List<Location>> queryLocationByAlias(
  1. String alias
)

Retrieve an array of third-party network locations from a Matrix room alias.

alias The Matrix room alias to look up.

Implementation

Future<List<Location>> queryLocationByAlias(String alias) async {
  final requestUri = Uri(
    path: '_matrix/client/v3/thirdparty/location',
    queryParameters: {
      'alias': alias,
    },
  );
  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) => Location.fromJson(v as Map<String, Object?>))
      .toList();
}