UDownloads class abstract final

Resumable, multi-connection downloads with a queue, notifications and restart recovery, on all 6 platforms (web: browser download). final task = await UDownloads.download(url);

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

active → List<UDownloadTask>
Downloads running right now.
no setter
allTasks → List<UDownloadTask>
Every download, including silent ones.
no setter
completed → List<UDownloadTask>
Finished downloads.
no setter
config → UDownloadConfig
Current settings (connections, concurrency, speed limit, Wi-Fi only…).
no setter
events → Stream<UDownloadTask>
Emits a task every time its status or progress changes. UDownloads.events.listen((t) => print(t.progress))
no setter
failed → List<UDownloadTask>
Failed downloads.
no setter
headersProvider ← Future<Map<String, String>> Function(UDownloadTask task)?
Adds headers (e.g. auth) to each download right before it starts. UDownloads.headersProvider = (t) async => {"Authorization": "Bearer ${ULocalStorage.getToken()}"}
no getter
isDownloading → bool
True while anything is downloading.
no setter
manager → UDownloadManager
The download manager itself, for listeners and advanced options.
no setter
maxConcurrent ← int
How many downloads run at once. UDownloads.maxConcurrent = 2
no getter
speedLimit ← int
Speed limit in bytes/second, 0 = unlimited. UDownloads.speedLimit = 500 * 1024
no getter
tasks → List<UDownloadTask>
Visible downloads, newest first (for your own list UI).
no setter
totalSpeed → double
Combined speed of running downloads in bytes/second. UDownloads.totalSpeed.toBKMG()
no setter
urlResolver ← Future<String> Function(UDownloadTask task)?
Rewrites a download URL right before it starts (e.g. fresh signed URLs).
no getter

Static Methods

bytes(String url, {Map<String, String> headers = const <String, String>{}, void onProgress(double progress)?, int connections = 1}) → Future<Uint8List>
Downloads into memory silently (no list entry, no notification). final Uint8List data = await UDownloads.bytes(url)
cancel(String id) → Future<void>
Stops a download and deletes its partial data.
clearFinished() → Future<void>
Removes finished and failed downloads from the list.
download(String url, {UDownloadDestination destination = const UDownloadDestination.downloads(), String? fileName, Map<String, String> headers = const <String, String>{}, bool wifiOnly = false, int? connections, UChecksum? checksum}) → Future<UDownloadTask>
Downloads url into Downloads (or destination) with progress, pause and resume; shows a notification. await UDownloads.download("https://x.com/a.zip")
enqueue(UDownloadRequest request) → Future<UDownloadTask>
Queues a fully custom request (headers, checksum, priority, connections…). await UDownloads.enqueue(UDownloadRequest(url: url, priority: 10))
fetchToStorage(String url, String key, {UStorageBucket bucket = UStorageBucket.support, Map<String, String> headers = const <String, String>{}, void onProgress(double progress)?, UChecksum? checksum, Duration? expireIn, bool persistent = true}) → Future<String>
Downloads silently into app storage and returns key when done.
init({UDownloadConfig? config}) → Future<void>
Loads saved downloads and starts the queue (runs on first use by itself).
open(UDownloadTask task) → Future<bool>
Opens a finished download with its default app.
openPage() → Future<void>
Opens the built-in download manager screen. UDownloads.openPage()
pause(String id) → Future<void>
Pauses a download (resumes later from the same byte).
pauseAll() → Future<void>
Pauses every download.
remove(String id, {bool deleteFile = false}) → Future<void>
Removes a download from the list; deleteFile deletes the file too.
resume(String id) → Future<void>
Resumes a paused download.
resumeAll() → Future<void>
Resumes every paused download.
retry(String id) → Future<void>
Starts a failed download again.
reveal(UDownloadTask task) → Future<bool>
Shows a finished download in the file manager.
saveAs(String url, {String? fileName, Map<String, String> headers = const <String, String>{}}) → Future<UDownloadTask>
Downloads and asks the user where to save it.
share(UDownloadTask task) → Future<void>
Opens the share sheet for a finished download.
task(String id) → UDownloadTask?
Finds a download by id.
text(String url, {Map<String, String> headers = const <String, String>{}}) → Future<String>
Downloads text silently. final String json = await UDownloads.text(url)
toFile(String url, String path, {Map<String, String> headers = const <String, String>{}, bool wifiOnly = false}) → Future<UDownloadTask>
Downloads to an exact file path (not on web). await UDownloads.toFile(url, "/tmp/a.zip")
toStorage(String url, String key, {UStorageBucket bucket = UStorageBucket.support, Map<String, String> headers = const <String, String>{}}) → Future<UDownloadTask>
Downloads into app storage under key; read it with UFile.readBytes(key). await UDownloads.toStorage(url, "pdfs/book.pdf")
toVault(String url, String key, {Map<String, String> headers = const <String, String>{}}) → Future<UDownloadTask>
Downloads encrypted into the vault under key; read with UFile.readSecure(key).