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 it's 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)) {
    if (Platform.isIOS) {
      Map<String, dynamic> properties = {name: value};
      _channel.invokeMethod<void>('union',
          <String, dynamic>{'token': this._token, 'properties': properties});
    } else {
      _channel.invokeMethod<void>('union', <String, dynamic>{
        'token': this._token,
        'name': name,
        'value': value
      });
    }
  } else {
    developer.log('`people union` failed: name cannot be blank',
        name: 'Mixpanel');
  }
}