logEvent method

Future<void> logEvent({
  1. required String name,
  2. Map<String, dynamic>? parameters,
  3. double? valueToSum,
})

Log an app event with the specified name and the supplied parameters value.

The native SDKs only accept String and numeric parameter values; an event containing any other value type is silently dropped by the SDK. This method therefore accepts String, num, and bool values — booleans are converted to "1"/"0" (Meta's yes/no convention, see paramValueYes/paramValueNo) so the event is recorded identically on both platforms. Any other value type (lists, maps, ...) throws an ArgumentError; encode structured values as a JSON string first (as Meta prescribes for paramNameContent).

See documentation:

Implementation

Future<void> logEvent({
  required String name,
  Map<String, dynamic>? parameters,
  double? valueToSum,
}) {
  final args = <String, dynamic>{
    'name': name,
    _paramNameValueToSum: valueToSum,
  };

  if (parameters != null) {
    args['parameters'] = _normalizeParameters(parameters);
  }

  return _channel.invokeMethod<void>('logEvent', _filterOutNulls(args));
}