setUserAttribute method

void setUserAttribute(
  1. String userAttributeName,
  2. dynamic userAttributeValue
)

Tracks a user attribute. Supported attribute types:

  • String int, double, num, bool
  • List<String>, List<int>, List<double>, List<num> , List
  • Valid JSON Object with Map and Valid JSON Array with List userAttributeValue - Data of type dynamic userAttributeName - Name of User Attribute

Implementation

void setUserAttribute(String userAttributeName, dynamic userAttributeValue) {
  if (userAttributeName.isEmpty) {
    Logger.w('User Attribute Name cannot be empty');
    return;
  }
  final filteredData = filterSupportedTypes(userAttributeValue);
  if (filteredData != null) {
    _platform.setUserAttribute(userAttributeName, filteredData, appId);
  } else {
    Logger.w(
        'Only String, Numbers, Bool, List and JSON Object values are supported as User Attributes, provided name: $userAttributeName, value: $userAttributeValue');
  }
}