cancel method

Future<bool> cancel()

Cancels this Job and waits for any asynchronous, server-side operations to be canceled.

The job is canceled and will result in a JobStatus.failed status after all cancellation tasks have completed. For jobs running on a server, a cancel request is sent for the associated Job.serverJobId. You should always cancel unneeded jobs (for example when exiting your app) to avoid placing unnecessary load on the server. Examples of server-side jobs include:

In addition, the GenerateOfflineMapJob is composed of several server-side jobs, depending on the types of layers in your ArcGISMap. Canceling this high-level job will also send a cancel request to the underlying server jobs.

Upon calling this method, the Job.status is immediately set to JobStatus.canceling.

Return Value: The Future returns true if the job was successfully canceled, false otherwise. The Future always completes without an error. Returns false if server jobs were requested to cancel but the response was not successful. Also returns false if the job has reached JobStatus.succeeded or JobStatus.failed status.

Implementation

Future<bool> cancel() {
  final taskHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_Job_cancelAsync(_handle, errorHandler);
  });
  return taskHandle.toFuture((element) => element.getValueAsBool()!);
}