addComment static method

EventHandler? addComment({
  1. required OverlayItem item,
  2. required String comment,
  3. void onComplete(
    1. GemError error
    )?,
})

Adds a text comment to an existing social report.

Submits user commentary on a social report, visible to all users viewing that report. Comments support community discussion and provide additional context. The comment appears in OverlayItem.previewData. Operation executes asynchronously with result delivered via onComplete callback.

Parameters

  • item: The social report OverlayItem to comment on. Must be a valid social report from alarm notification or map selection.
  • comment: Comment text content.
  • onComplete: Callback invoked when operation completes or fails. Called with:

Returns

  • EventHandler if operation was successfully initiated (use with cancel).
  • null if operation could not be started.

See also:

Implementation

static EventHandler? addComment({
  required final OverlayItem item,
  required final String comment,
  void Function(GemError error)? onComplete,
}) {
  final EventDrivenProgressListener progListener =
      EventDrivenProgressListener();
  GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);

  progListener.registerOnCompleteWithData((final int err, _, _) {
    GemKitPlatform.instance.unregisterEventHandler(progListener.id);
    onComplete?.call(GemErrorExtension.fromCode(err));
  });

  final OperationResult result = staticMethod(
    'SocialOverlay',
    'addComment',
    args: <String, dynamic>{
      'item': item.pointerId,
      'comment': comment,
      'listener': progListener.id,
    },
  );

  final GemError error = GemErrorExtension.fromCode(result['result']);
  if (error != GemError.scheduled) {
    GemKitPlatform.instance.unregisterEventHandler(progListener.id);
    onComplete?.call(error);
    return null;
  }

  return progListener;
}