resume method
Resume (after a pause) the ongoing foreground download
It is not usually necessary to use the result. Returns null if there is
no ongoing download or the download is already running. Returns true if
the download was paused. Returns false if the download was pausing (
in which case the download will not be paused).
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.
Implementation
bool? resume({Object instanceId = 0}) {
final instance = DownloadInstance.get(instanceId);
if (instance == null ||
(!instance.isPaused && instance.resumingAfterPause == null) ||
instance.requestResume == null) {
return null;
}
if (instance.pausingCompleter.isCompleted) {
instance.requestResume!();
return true;
}
if (!instance.resumingAfterPause!.isCompleted) {
instance
..resumingAfterPause!.complete(false)
..pausingCompleter.future.then((_) => instance.requestResume!());
}
return false;
}