addComment static method
- required OverlayItem item,
- required String comment,
- void onComplete(
- GemError error
Add a comment to 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
Throws
- An exception if it fails.
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;
}