deleteProfileField method

Future<Map<String, Object?>> deleteProfileField(
  1. String userId,
  2. String keyName
)

Remove a specific field from a user's profile.

userId The user whose profile field should be deleted.

keyName The name of the profile field to delete.

Implementation

Future<Map<String, Object?>> deleteProfileField(
  String userId,
  String keyName,
) async {
  final requestUri = Uri(
    path:
        '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/${Uri.encodeComponent(keyName)}',
  );
  final request = Request('DELETE', 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 Map<String, Object?>;
}