pauseDownload method

GemError pauseDownload({
  1. void onComplete(
    1. GemError
    )?,
})

Pause a running or previously started download.

Calling this method asks the underlying service to suspend an in-progress download. When the pause request completes the original download onComplete callback (the one passed to asyncDownload) will be invoked with a GemError.suspended result to indicate the download stopped due to suspension.

While a pause is being processed you should avoid performing other operations on the same ContentStoreItem instance. Use the onComplete callback to detect when it is safe to proceed.

Use asyncDownload to start or resume downloads after a pause.

Parameters

  • onComplete: optional callback invoked when the pause request finishes. The callback receives a single GemError argument. On success it will be GemError.success.

Returns

  • A GemError indicating immediate result of the pause request. See GemError values for possible outcomes.

Also see:

Implementation

GemError pauseDownload({void Function(GemError)? onComplete}) {
  final OperationResult resultString = objectMethod(
    pointerId,
    'ContentStoreItem',
    'pauseDownload',
  );

  final GemError err = GemErrorExtension.fromCode(resultString['result']);

  if (err == GemError.success && onComplete != null) {
    _tryNotifyComplete(onComplete: onComplete);
  }

  if (err != GemError.success) {
    onComplete?.call(err);
  }

  return err;
}