trackEvent method

void trackEvent({
  1. required String name,
  2. String? label,
  3. BatchEventData? data,
})

Track an event.

The event name is required and must not be empty. It should be composed of letters, numbers or underscores ([a-z0-9_]) and can’t be longer than 30 characters.

The event label is an optional string, which must not be empty or longer than 200 characters. If the label is too long, it will be ignored.

The event data is an optional object holding attributes and tags related to the event. See BatchEventData's documentation for more info.

Implementation

void trackEvent({required String name, String? label, BatchEventData? data}) {
  Map eventArgs = {"name": name, "label": label};
  if (data != null) {
    eventArgs["event_data"] = data.internalGetBridgeRepresentation();
  }
  _channel.invokeMethod("user.track.event", eventArgs);
}