cancel method
Cancel the ongoing foreground download and recovery session
Will return once the cancellation is complete. Note that all running parallel download threads will be allowed to finish their current tile download, and buffered tiles will be written. There is no facility to cancel the download immediately, as this would likely cause unwanted behaviour.
By default, only one download is allowed at any one time, across all stores.
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.
Note that instances are shared across all stores.
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.
Implementation
Future<void> cancel({Object instanceId = 0}) async =>
await DownloadInstance.get(instanceId)?.requestCancel?.call();