getReportSnapshot static method
Retrieves the image snapshot associated with a social report.
Downloads the photo attached to a social report when submitted with image
data. Only applicable to Social Reports Overlay items. Returns image via
onComplete callback with Img result. Operation executes asynchronously
with progress tracking.
Parameters
item: The social report OverlayItem containing snapshot. Must be a valid social report from alarm notification or map selection.onComplete: Callback invoked when operation completes or fails. Called with error code and image:- GemError.success with Img when snapshot is retrieved successfully.
- GemError.invalidInput if
itemis not a social report overlay item or not from alarm notification. - GemError.connectionRequired if no data connection is available.
Returns
- ProgressListener for tracking operation progress if started successfully.
nullif operation could not be started.
See also:
- report - Submits report with optional snapshot image.
Implementation
static ProgressListener? getReportSnapshot({
required final OverlayItem item,
required void Function(GemError error, Img? imageInfo) onComplete,
}) {
final ImgHolder result = ImgHolder();
final EventDrivenProgressListener listener = EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(listener.id, listener);
listener.registerOnCompleteWithData((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(listener.id);
if (err == 0) {
onComplete(GemErrorExtension.fromCode(err), result.value);
} else {
onComplete(GemErrorExtension.fromCode(err), null);
}
result.dispose();
});
staticMethod(
'SocialOverlay',
'getReportSnapshot',
args: <String, dynamic>{
'item': item.pointerId,
'image': result.pointerId,
'listener': listener.id,
},
);
final GemError err = ApiErrorService.apiError;
if (err != GemError.success) {
GemKitPlatform.instance.unregisterEventHandler(listener.id);
onComplete(err, null);
return null;
}
return listener;
}