addComment static method
EventHandler?
addComment({
- required OverlayItem item,
- required String comment,
- void onComplete(
- 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:- GemError.success when comment is successfully submitted.
- GemError.invalidInput if
itemis not a social report overlay item or not from alarm notification. - GemError.connectionRequired if no data connection is available.
- GemError.busy if another add comment operation is in progress.
Returns
EventHandlerif operation was successfully initiated (use with cancel).nullif operation could not be started.
See also:
- confirmReport - Upvotes the report validity.
- denyReport - Downvotes the report validity.
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;
}