configureNotificationForGroup method
- String group, {
- TaskNotification? running,
- TaskNotification? complete,
- TaskNotification? error,
- TaskNotification? paused,
- bool progressBar = false,
- bool tapOpensFile = false,
- String groupNotificationId = '',
Configure notification for a group of tasks
The configuration determines what notifications are shown, whether a progress bar is shown (Android only), and whether tapping the 'complete' notification opens the downloaded file.
running
is the notification used while the task is in progress
complete
is the notification used when the task completed
error
is the notification used when something went wrong,
including pause, failed and notFound status
progressBar
if set will show a progress bar
tapOpensFile
if set will attempt to open the file when the complete
notification is tapped
groupNotificationId
if set will group all notifications with the same
groupNotificationId
and change the progress bar to number of finished
tasks versus total number of tasks in the groupNotificationId
.
Use {numFinished} and {numTotal} tokens in the TaskNotification.title
and TaskNotification.body to substitute. Task-specific substitutions
such as {filename} are not valid when using groupNotificationId
.
The groupNotificationId
is considered complete
when there are no
more tasks running within that group, and at that point the
complete
notification is shown (if configured). If any task in the
groupNotificationId
fails, the error
notification is shown.
The first character of the groupNotificationId
cannot be '*'.
The TaskNotification is the actual notification shown for a Task, and
body
and title
may contain special strings to substitute display values:
{filename} to insert the Task.filename
{metaData} to insert the Task.metaData
{displayName} to insert the Task.displayName
{progress} to insert progress in %
{networkSpeed} to insert the network speed in MB/s or kB/s, or '--' if N/A
{timeRemaining} to insert the estimated time remaining to complete the task
in HH:MM:SS or MM:SS or --:-- if N/A
{numFinished} to insert the number of finished tasks in a groupNotification
{numFailed} to insert the number of failed tasks in a groupNotification
{numTotal} to insert the number of tasks in a groupNotification
Actual appearance of notification is dependent on the platform, e.g. on iOS {progress} is not available and ignored (except for groupNotifications)
Returns the FileDownloader for easy chaining
Implementation
FileDownloader configureNotificationForGroup(String group,
{TaskNotification? running,
TaskNotification? complete,
TaskNotification? error,
TaskNotification? paused,
bool progressBar = false,
bool tapOpensFile = false,
String groupNotificationId = ''}) {
_downloader.notificationConfigs.add(TaskNotificationConfig(
taskOrGroup: group,
running: running,
complete: complete,
error: error,
paused: paused,
progressBar: progressBar,
tapOpensFile: tapOpensFile,
groupNotificationId: groupNotificationId));
return this;
}