Flutter 0.5.54 Download

Download

A plugin for creating and managing download tasks. Supports iOS and Android.

This plugin is based on WorkManager in Android and NSURLSessionDownloadTask in iOS to run download task in background mode.

Flutter for mac 0.5.54 介绍Flutter是在Mac OS X下使用Kinect的手势通过内置的摄像头在您的设备来播放,暂停和跳过歌曲和视频,支持 iTunes,Spotify,RDIO:MPlayerX(最新版本),VLC(最新版本), E.,MAC版下载 苹果正式版 注册版 破解版 download apple iphone ipad 苹果专卖店.

iOS integration #

Required configuration: #

Note: following steps requires to open your ios project in Xcode.

  • Enable background mode.
  • Add sqlite library.
  • Configure AppDelegate:

Objective-C:

Or Swift:

Optional configuration: #

  • Support HTTP request: if you want to download file with HTTP request, you need to disable Apple Transport Security (ATS) feature. There're two options:
  1. Disable ATS for a specific domain only: (add following codes to your Info.plist file)
  1. Completely disable ATS: (add following codes to your Info.plist file)
  • Configure maximum number of concurrent tasks: the plugin allows 3 download tasks running at a moment by default (if you enqueue more than 3 tasks, there're only 3 tasks running, other tasks are put in pending state). You can change this number by adding following codes to your Info.plist file.
  • Localize notification messages: the plugin will send a notification message to notify user in case all files are downloaded while your application is not running in foreground. This message is English by default. You can localize this message by adding and localizing following message in Info.plist file. (you can find the detail of Info.plist localization in this link)

Note:

  • This plugin only supports save files in NSDocumentDirectory

Android integration #

Required configuration: #

  • If your project is running on Flutter versions prior v1.12, have a look at this document to configure your Android project.

  • From Flutter v1.12 with Android v2 embedding there's no additional configurations required to work with background isolation in Android (but you need to setup your project properly. See upgrading pre 1.12 Android projects)

  • In order to handle click action on notification to open the downloaded file on Android, you need to add some additional configurations. Add the following codes to your AndroidManifest.xml:

Note:

  • You have to save your downloaded files in external storage (where the other applications have permission to read your files)
  • The downloaded files are only able to be opened if your device has at least an application that can read these file types (mp3, pdf, etc)

Optional configuration: #

  • Configure maximum number of concurrent tasks: the plugin depends on WorkManager library and WorkManager depends on the number of available processor to configure the maximum number of tasks running at a moment. You can setup a fixed number for this configuration by adding following codes to your AndroidManifest.xml:
  • Localize notification messages: you can localize notification messages of download progress by localizing following messages. (you can find the detail of string localization in Android in this link)
  • PackageInstaller: in order to open APK files, your application needs REQUEST_INSTALL_PACKAGES permission. Add following codes in your AndroidManifest.xml:

Usage #

Import package:

Initialize

  • Note: the plugin must be initialized before using.

Create new download task:

Update download progress:

Important note: your UI is rendered in the main isolate, while download events come from a background isolate (in other words, codes in callback are run in the background isolate), so you have to handle the communication between two isolates. For example:

Load all tasks:

Load tasks with conditions:

  • Note: In order to parse data into DownloadTask object successfully, you should load data with all fields from DB (in the other word, use: SELECT * ). For example:
  • Note: the following is the schema of task table where this plugin stores tasks information

Cancel a task:

Cancel all tasks:

Pause a task:

Resume a task:

  • Note: resume() will return a new taskId corresponding to a new background task that is created to continue the download process. You should replace the original taskId (that is marked as paused status) by this new taskId to continue tracking the download progress.

Retry a failed task:

  • Note: retry() will return a new taskId (like resume())

Remove a task:

Open and preview a downloaded file:

  • Note: in Android, you can only open a downloaded file if it is placed in the external storage and there's at least one application that can read that file type on your device.

Bugs/Requests #

If you encounter any problems feel free to open an issue. If you feel the library ismissing a feature, please raise a ticket on Github. Pull request are also welcome.