getPreviewData method
- void onResult(
- GemError error,
- SearchableParameterList? parameters
Get the traffic preview data as a list of parameters
Parameters
- IN onComplete Will be invoked when the operation is completed, providing the results and an error code.
- Will call with error code GemError.success and non-null results on success
- Will call with other error codes and null results on failure
Returns
- The ProgressListener associated to the request if it could be started, null otherwise
Throws
- An exception if it fails
Implementation
ProgressListener? getPreviewData(
void Function(GemError error, SearchableParameterList? parameters)
onResult) {
final EventDrivenProgressListener listener = EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(listener.id, listener);
final SearchableParameterList parameterList = SearchableParameterList();
listener.registerOnCompleteWithDataCallback((int code, _, __) {
final GemError error = GemErrorExtension.fromCode(code);
GemKitPlatform.instance.unregisterEventHandler(listener.id);
if (error != GemError.success) {
onResult(error, null);
} else {
onResult(error, parameterList);
}
});
final OperationResult resultString = objectMethod(
_pointerId,
'TrafficEvent',
'getPreviewData',
args: <String, dynamic>{
'first': parameterList.pointerId,
'second': listener.id,
},
);
if (resultString['result'] != 0) {
GemKitPlatform.instance.unregisterEventHandler(listener.id);
onResult(GemErrorExtension.fromCode(resultString['result']), null);
return null;
}
return listener;
}