setOnce method

void setOnce (
  1. String prop,
  2. String to

Works just like groupSet() except it will not overwrite existing property values. This is useful for properties like "First login date".

  • prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
  • to The value to set on the given property name. For "Zip Code", this value might be the String "90210"


void setOnce(String prop, String to) {
  if (_MixpanelHelper.isValidString(prop)) {
    Map<String, dynamic> properties = {prop: to};

    _channel.invokeMethod<void>('groupSetPropertyOnce', <String, dynamic>{
      'token': this._token,
      'groupKey': this._groupKey,
      'groupID': this._groupID,
      'properties': properties
  } else {
    developer.log('`group setOnce` failed: prop cannot be blank',
        name: 'Mixpanel');