pause method

Future<void> pause({
  1. Object instanceId = 0,
})

Pause the ongoing foreground download

Use resume to resume the download. It is also safe to use cancel without resuming first.

Will return once the pause operation is complete. Note that all running parallel download threads will be allowed to finish their current tile download. Any buffered tiles are not written.

By default, only one download is allowed at any one time.

However, if necessary, multiple can be started by setting methods' instanceId argument to a unique value on methods. Whatever object instanceId is, it must have a valid and useful equality and hashCode implementation, as it is used as the key in a Map. Note that this unique value must be known and remembered to control the state of the download.

Warning

Starting multiple simultaneous downloads may lead to a noticeable performance loss. Ensure you thoroughly test and profile your application.

Does nothing (returns immediately) if there is no ongoing download or the download is already paused.

Implementation

Future<void> pause({Object instanceId = 0}) async =>
    await DownloadInstance.get(instanceId)?.requestPause?.call();