setMemberAttributes method

Future<void> setMemberAttributes(
  1. {required String groupId,
  2. required Map<String, String> attributes,
  3. String? userId}
)

Sets custom attributes of a group member.

Param groupId The group ID.

Param userId The user ID of the group member for whom the custom attributes are set. The default value is the current user ID.

Param attributes The map of custom attributes in key-value format. In a key-value pair, if the value is set to an empty string, the custom attribute will be deleted.

Throws A description of the exception. See ChatError.

Implementation

Future<void> setMemberAttributes({
  required String groupId,
  required Map<String, String> attributes,
  String? userId,
}) async {
  Map req = {
    'groupId': groupId,
  };
  if (userId != null) {
    req.putIfNotNull('userId', userId);
  }
  req.putIfNotNull('attributes', attributes);
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.setMemberAttributesFromGroup, req);
  try {
    ChatError.hasErrorFromResult(result);
  } on ChatError catch (e) {
    throw e;
  }
}