FileDownloader class interface
Provides access to all functions of the plugin in a single place.
Constructors
- FileDownloader.new({PersistentStorage? persistentStorage})
-
factory
Properties
- database ↔ Database
-
Database where tracked tasks are stored.
latefinal
- downloaderForTesting → BaseDownloader
-
Do not use: for testing only
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- permissions → Permissions
-
Permissions authorization interface
no setter
-
ready
→ Future<
bool> -
True when initialization is complete and downloader ready for use
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
taskQueues
→ List<
TaskQueue> -
List of connected TaskQueues
no setter
-
updates
→ Stream<
TaskUpdate> -
Stream of TaskUpdate updates for downloads that do
not have a registered callback
no setter
- uri → UriUtils
-
Accesses utilities for working with URIs. URIs make working with file pickers and
shared storage easier, as they abstract permissions and are coherent
across platforms.
no setter
Methods
-
addTaskQueue(
TaskQueue taskQueue) → void -
Adds the
taskQueue
to this downloader -
allTaskIds(
{String group = defaultGroup, bool includeTasksWaitingToRetry = true, dynamic allGroups = false}) → Future< List< String> > -
Returns a list of taskIds of all tasks currently active in this
group
-
allTasks(
{String group = defaultGroup, bool includeTasksWaitingToRetry = true, bool allGroups = false}) → Future< List< Task> > -
Returns a list of all tasks currently active in this
group
-
cancel(
Task task) → Future< bool> - Cancel this task
-
cancelAll(
{Iterable< Task> ? tasks, String? group}) → Future<bool> -
Cancels all tasks, or those in
tasks
, or all tasks in groupgroup
-
cancelTasksWithIds(
Iterable< String> taskIds) → Future<bool> - Cancel all tasks matching the taskIds in the list
-
cancelTaskWithId(
String taskId) → Future< bool> - Cancel this task
-
configure(
{dynamic globalConfig, dynamic androidConfig, dynamic iOSConfig, dynamic desktopConfig}) → Future< List< (String, String)> > - Configures the downloader
-
configureNotification(
{TaskNotification? running, TaskNotification? complete, TaskNotification? error, TaskNotification? paused, TaskNotification? canceled, bool progressBar = false, bool tapOpensFile = false, String groupNotificationId = ''}) → FileDownloader - Configure default task notification
-
configureNotificationForGroup(
String group, {TaskNotification? running, TaskNotification? complete, TaskNotification? error, TaskNotification? paused, TaskNotification? canceled, bool progressBar = false, bool tapOpensFile = false, String groupNotificationId = ''}) → FileDownloader - Configure notification for a group of tasks
-
configureNotificationForTask(
Task task, {TaskNotification? running, TaskNotification? complete, TaskNotification? error, TaskNotification? paused, TaskNotification? canceled, bool progressBar = false, bool tapOpensFile = false, String groupNotificationId = ''}) → FileDownloader - Configure notification for a single task
-
destroy(
) → void - Destroy the FileDownloader. Subsequent use requires initialization
-
download(
DownloadTask task, {void onStatus(TaskStatus)?, void onProgress(double)?, void onElapsedTime(Duration)?, Duration? elapsedTimeInterval}) → Future< TaskStatusUpdate> - Download a file and return the final TaskStatusUpdate
-
downloadBatch(
List< DownloadTask> tasks, {BatchProgressCallback? batchProgressCallback, TaskStatusCallback? taskStatusCallback, TaskProgressCallback? taskProgressCallback, void onElapsedTime(Duration)?, Duration? elapsedTimeInterval}) → Future<Batch> -
Enqueues a list of files to download and returns when all downloads
have finished (successfully or otherwise). The returned value is a
Batch object that contains the original
tasks
, theresults
and convenience getters to filter successful and failed results. -
enqueue(
Task task) → Future< bool> - Enqueue a new Task
-
enqueueAll(
Iterable< Task> tasks) → Future<List< bool> > - Enqueues a list of tasks and returns a list of booleans indicating whether each task was successfully enqueued
-
getRequireWiFiSetting(
) → Future< RequireWiFi> - Returns the current global setting for requiring WiFi
-
Move the file represented by
filePath
to a shared storagedestination
and potentially adirectory
within that destination. If themimeType
is not provided we will attempt to derive it from thefilePath
extension -
Move the file represented by the
task
to a shared storagedestination
and potentially adirectory
within that destination. If themimeType
is not provided we will attempt to derive it from the Task.filePath extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openFile(
{Task? task, String? filePath, String? mimeType}) → Future< bool> -
Open the file represented by
task
orfilePath
using the application available on the platform. -
Returns the filePath to the file represented by
filePath
in shared storagedestination
and potentially adirectory
within that destination. -
pause(
DownloadTask task) → Future< bool> - Pause the task
-
pauseAll(
{Iterable< DownloadTask> ? tasks, String? group}) → Future<List< DownloadTask> > -
Pauses all tasks, or those in
tasks
, or all tasks in groupgroup
-
platformVersion(
) → Future< String> - Return the platform version as a String
-
registerCallbacks(
{String group = defaultGroup, TaskStatusCallback? taskStatusCallback, TaskProgressCallback? taskProgressCallback, TaskNotificationTapCallback? taskNotificationTapCallback}) → FileDownloader - Register status or progress callbacks to monitor download progress, and TaskNotificationTapCallback to respond to user tapping a notification.
-
removeTaskQueue(
TaskQueue taskQueue) → bool -
Removes
taskQueue
and return true if successful -
request(
Request request) → Future< Response> -
Perform a server request for this
request
-
requireWiFi(
RequireWiFi requirement, {dynamic rescheduleRunningTasks = true}) → Future< bool> -
Set WiFi requirement globally, based on
requirement
. -
rescheduleKilledTasks(
) → Future< (List< Task> , List<Task> )> - Reschedules tasks that are present in the database but missing from the native task queue. Typically called on app start, 5s after establishing the updates listener, calling trackTasks or trackTasksInGroup and calling resumeFromBackground.
-
reset(
{String group = defaultGroup}) → Future< int> -
Resets the downloader by cancelling all ongoing tasks within
the provided
group
-
resetUpdates(
) → Future< void> - Closes the updates stream and re-initializes the StreamController such that the stream can be listened to again
-
resume(
DownloadTask task) → Future< bool> - Resume the task
-
resumeAll(
{Iterable< DownloadTask> ? tasks, String? group, Duration interval = const Duration(milliseconds: 50)}) → Future<List< Task> > -
Resume all paused tasks, or those in
tasks
, or paused tasks in groupgroup
-
resumeFromBackground(
) → Future< void> - Wakes up the FileDownloader from possible background state, triggering a stream of updates that may have been processed while in the background, and have not yet reached the callbacks or listener
-
start(
{bool doTrackTasks = true, bool markDownloadedComplete = true, bool doRescheduleKilledTasks = true}) → Future< void> - Convenience start method for using the database. Must be called AFTER registering update callbacks or listener.
-
taskCanResume(
Task task) → Future< bool> - Returns true if task can be resumed on pause
-
taskForId(
String taskId) → Future< Task?> -
Return Task for the given
taskId
, or null if not found. -
tasksFinished(
{String group = defaultGroup, bool includeTasksWaitingToRetry = true, String? ignoreTaskId}) → Future< bool> -
Returns true if tasks in this
group
are finished -
toString(
) → String -
A string representation of this object.
inherited
-
trackTasks(
{bool markDownloadedComplete = true}) → Future< FileDownloader> - Activate tracking for all tasks
-
trackTasksInGroup(
String group, {bool markDownloadedComplete = true}) → Future< FileDownloader> -
Activate tracking for tasks in this
group
-
transmit(
DataTask task, {void onStatus(TaskStatus)?, void onElapsedTime(Duration)?, Duration? elapsedTimeInterval}) → Future< TaskStatusUpdate> - Transmit data in the DataTask and receive the response
-
unregisterCallbacks(
{String group = defaultGroup, Function? callback}) → FileDownloader - Unregister a previously registered TaskStatusCallback, TaskProgressCallback or TaskNotificationTapCallback.
-
upload(
UploadTask task, {void onStatus(TaskStatus)?, void onProgress(double)?, void onElapsedTime(Duration)?, Duration? elapsedTimeInterval}) → Future< TaskStatusUpdate> - Upload a file and return the final TaskStatusUpdate
-
uploadBatch(
List< UploadTask> tasks, {BatchProgressCallback? batchProgressCallback, TaskStatusCallback? taskStatusCallback, TaskProgressCallback? taskProgressCallback, void onElapsedTime(Duration)?, Duration? elapsedTimeInterval}) → Future<Batch> -
Enqueues a list of files to upload and returns when all uploads
have finished (successfully or otherwise). The returned value is a
Batch object that contains the original
tasks
, theresults
and convenience getters to filter successful and failed results.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- chunkGroup → String
-
Special group name for tasks that download a chunk, as part of a
ParallelDownloadTask
no setter
Constants
- defaultGroup → const String
- If no group is specified the default group name will be used