setAttribute

Sets a custom attribute for the device.

Syntax 

1Future<void> setAttribute(String key, Object? value)

Parameters 

  • key (String) - The attribute key
  • value (Object?) - The attribute value

Returns 

  • Future<void> - Completes when the attribute has been set.

Example 

1try {
2  await SfmcSdk.setAttribute('userType', 'premium');
3  await SfmcSdk.setAttribute('lastLogin', DateTime.now().toIso8601String());
4  print('Attributes set successfully');
5} catch (e) {
6  print('Failed to set attribute: $e');
7}

Related Methods