setAttribute method

Future<bool>? setAttribute({
  1. required Map<String, dynamic> attributes,
  2. required VWOContext vwoContext,
})

Sets a user attribute.

attributeKey The key of the attribute. attributeValue The value of the attribute. vwoContext The user context for the attribute.

Returns a Future that resolves to a boolean indicating the success status of setting the attribute.

Implementation

Future<bool>? setAttribute({
  required Map<String, dynamic> attributes,
  required VWOContext vwoContext,
}) async {
  try {
    final plugin = _fmePlugin;
    if (plugin == null) return false;

    return plugin.setAttribute(
        attributes: attributes,
        userContext: vwoContext);
  } catch (e) {
    String details;
    if (e is PlatformException) {
      details = e.message ?? '';
    } else {
      details = e.toString();
    }
    logMessage('VWO: Failed to set attribute $details');
    return false;
  }
}