addComment static method
- required OverlayItem item,
- required String comment,
- void onComplete(
- GemError error
Adds a comment to a report.
Parameters
- IN item The report overlay item.
- IN comment The comment.
- IN onComplete Callback to be called when the request is completed, provides the error code:
- GemError.invalidInput - Invalid item (not a social report overlay item) or item is not a result of alarm notification.
- GemError.connectionRequired - No internet connection available.
- GemError.busy - Another add comment operation is in progress.
- GemError.success - Comment added.
Returns
- The operation handler if the operation could be started, null otherwise.
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.registerOnCompleteWithDataCallback((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;
}