union method Null safety

void union(
  1. String name,
  2. List value
)

Adds values to a list-valued property only if they are not already present in the list. If the property does not currently exist, it will be created with the given list as its value. If the property exists and is not list-valued, the union will be ignored.

  • name name of the list-valued property to set or modify
  • value an array of values to add to the property value if not already present

Implementation

void union(String name, List<dynamic> value) {
  if (!_MixpanelHelper.isValidString(name)) {
    developer.log('`group union` failed: name cannot be blank',
        name: 'Mixpanel');
    return;
  }
  // ignore: unnecessary_null_comparison
  if (value == null) {
    developer.log('`group union` failed: value cannot be blank',
        name: 'Mixpanel');
    return;
  }
  _channel.invokeMethod<void>('groupUnionProperty', <String, dynamic>{
    'token': this._token,
    'groupKey': this._groupKey,
    'groupID': this._groupID,
    'name': name,
    'value': value
  });
}