FileDownloader class
FlutterFileDownloader core file that handles native calls
Constructors
- FileDownloader()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLogEnabled → bool
-
no setter
- maximumParallelDownloads → int
-
no setter
- 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 Methods
-
cancelDownload(
int downloadId) → Future< bool> - to cancel a download request by it's id
-
downloadFile(
{required String url, String? name, NotificationType notificationType = NotificationType.progressOnly, DownloadDestinations downloadDestination = DownloadDestinations.publicDownloads, Map< String, String> headers = const {}, OnDownloadRequestIdReceived? onDownloadRequestIdReceived, OnProgress? onProgress, OnDownloadCompleted? onDownloadCompleted, OnDownloadError? onDownloadError}) → Future<File?> -
url
the file url you want to downloadname
the file name after download, this will be file name inside your dowloads directory if this was null, then the last segment of the url will be used as the name the name can be written with the extension, if not, the extension will be extracted from the urldownloadDestination
the desired download location, this can either be public download directory (Default) or the app's private files directoryonDownloadRequestIdReceived
triggered when downloading service get the task and returns the new task id this callback must be used when wanting to cancel the downloadonProgress
when the download progress change, you can update your UI or do anything you want Note, some devices or urls jumps from 0 to 100 in one steponDownloadCompleted
When the download is complete, this callback will be fired holding the file pathonDownloadError
When something unexpected happens, this callback will be fired -
downloadFiles(
{required List< String> urls, NotificationType notificationType = NotificationType.progressOnly, DownloadDestinations downloadDestination = DownloadDestinations.publicDownloads, bool isParallel = true, VoidCallback? onAllDownloaded, Map<String, String> headers = const {}}) → Future<List< File?> > -
urls
a list of urls to files to be downloadeddownloadDestination
the desired download location, this can either be public download directory (Default) or the app's private files directoryisParallel
this indicates that the download process must be parallel or download file by file to reduce device's resource consumption if this is set to true (Default), this will not exceedMaximumParallelDownloads
(25 by default)onAllDownloaded
this callback will be triggered once all files downloaded are done note that some of the files might fail downloading and the files will be in the same order of the urls a filed to download file will be null at it's index -
downloadFilesWithCustomHeaders(
{required List< DownloadFileRequest> requests, NotificationType notificationType = NotificationType.progressOnly, DownloadDestinations downloadDestination = DownloadDestinations.publicDownloads, bool isParallel = true, VoidCallback? onAllDownloaded}) → Future<List< File?> > - A batch-download request method to pass a different headers for each file
-
setLogEnabled(
bool enabled) → void -
enabled
To print logs for downloading status & callbacks -
setMaximumParallelDownloads(
int maximumParallelDownloads) → void -
maximumParallelDownloads
if this is not set, the default is_upperLimitParallelDownloads
by using this method, you can limit the parallel downloads for example, if you set this value to 10 and requested to download 20 files at the same time the files will be downloaded in two batches, 10 files each