setOnce method Null safety

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

Works just like set(), 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 of the Mixpanel property. For "Zip Code", this value might be the String "90210"

Implementation

void setOnce(String prop, dynamic to) {
  if (_MixpanelHelper.isValidString(prop)) {
    Map<String, dynamic> properties = {prop: to};
    _channel.invokeMethod<void>('setOnce',
        <String, dynamic>{'token': this._token, 'properties': properties});
  } else {
    developer.log('`people setOnce` failed: prop cannot be blank',
        name: 'Mixpanel');
  }
}