al_downloader 1.3.6 copy "al_downloader: ^1.3.6" to clipboard
al_downloader: ^1.3.6 copied to clipboard

outdated

A URL-based flutter downloader that supports to download any type of file and automatically manages a lot of things.

al_downloader #

pub package

A URL-based flutter downloader that supports to download any type of file and automatically manages a lot of things.

If you need Chinese Document, click here.

Features #

  • manage download tasks by url
  • simple download status
  • I/O infrequently
  • provide convenient download handle
  • support batch download
  • manage automatically files without requiring to be specified a download path
  • based on flutter_downloader

Integration #

Native Config: same as flutter_downloader native config

add the following line to your pubspec.yaml

dependencies:
  al_downloader: ^1.3.5

run the following line with your command line

flutter packages get

import the following line, then you can use al_downloader

import 'package:al_downloader/al_downloader.dart';

Usage #

ALDownloader #

/// download
await ALDownloader.download(url,
    downloaderHandlerInterface:
        ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          "ALDownloader | download progress = $progress, url = $url");
    }, succeededHandler: () {
      debugPrint("ALDownloader | download succeeded, url = $url");
    }, failedHandler: () {
      debugPrint("ALDownloader | download failed, url = $url");
    }, pausedHandler: () {
      debugPrint("ALDownloader | download paused, url = $url");
    }));
/// add a downloader handler interface
ALDownloader.addDownloaderHandlerInterface(
    ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          "ALDownloader | download progress = $progress, url = $url");
    }, succeededHandler: () {
      debugPrint("ALDownloader | download succeeded, url = $url");
    }, failedHandler: () {
      debugPrint("ALDownloader | download failed, url = $url");
    }, pausedHandler: () {
      debugPrint("ALDownloader | download paused, url = $url");
    }),
    url);
/// add a forever downloader handler interface
ALDownloader.addForeverDownloaderHandlerInterface(
    ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          "ALDownloader | download progress = $progress, url = $url");
    }, succeededHandler: () {
      debugPrint("ALDownloader | download succeeded, url = $url");
    }, failedHandler: () {
      debugPrint("ALDownloader | download failed, url = $url");
    }, pausedHandler: () {
      debugPrint("ALDownloader | download paused, url = $url");
    }),
    url);
/// remove downloader handler interface
ALDownloader.removeDownloaderHandlerInterfaceForUrl(url);
ALDownloader.removeDownloaderHandlerInterfaceForAll;
/// get download status for [url]
ALDownloaderStatus status = ALDownloader.getDownloadStatusForUrl(url);
/// get download progress for [url]
final progress = ALDownloader.getDownloadProgressForUrl(url);
/// cancel
///
/// for details, see interface description
await ALDownloader.cancel(url);
await ALDownloader.cancelAll;
/// pause
///
/// for details, see interface description
await ALDownloader.pause(url);
await ALDownloader.pauseAll;
/// remove
///
/// for details, see interface description
await ALDownloader.remove(url);
await ALDownloader.removeAll;

ALDownloaderBatcher #

/// batch download
await ALDownloaderBatcher.downloadUrls(urls,
    downloaderHandlerInterface:
        ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint("ALDownloader | batch | download progress = $progress");
    }, succeededHandler: () {
      debugPrint("ALDownloader | batch | download succeeded");
    }, failedHandler: () {
      debugPrint("ALDownloader | batch | download failed");
    }, pausedHandler: () {
      debugPrint("ALDownloader | batch | download paused");
    }));
/// summarize the download status for a set of urls
final status = ALDownloaderBatcher.getDownloadStatusForUrls(urls);

ALDownloaderPersistentFileManager - persistent file management by url #

final model = await ALDownloaderPersistentFileManager
    .lazyGetALDownloaderPathModelForUrl(url);
debugPrint(
    "ALDownloader | get the 'physical directory path' and 'virtual/physical file name' of the file for [url], url = $url, model = $model\n");

final path2 = await ALDownloaderPersistentFileManager
    .getAbsolutePathOfDirectoryForUrl(url);
debugPrint(
    "ALDownloader | get 'directory path' for [url], url = $url, path = $path2\n");

final path3 = await ALDownloaderPersistentFileManager
    .getAbsoluteVirtualPathOfFileForUrl(url);
debugPrint(
    "ALDownloader | get 'virtual file path' for [url], url = $url, path = $path3\n");

final path4 = await ALDownloaderPersistentFileManager
    .getAbsolutePhysicalPathOfFileForUrl(url);
debugPrint(
    "ALDownloader | get 'physical file path' for [url], url = $url, path = $path4\n");

final isExist = await ALDownloaderPersistentFileManager
    .isExistAbsolutePhysicalPathOfFileForUrl(url);
debugPrint(
    "ALDownloader | check whether [url] has a physical path, url = $url, is Exist = $isExist\n");

final fileName = ALDownloaderPersistentFileManager.getFileNameForUrl(url);
debugPrint(
    "ALDownloader | get 'virtual/physical file name' for [url], url = $url, file name = $fileName\n");

Note: #

If the persistent file was removed by exceptional means, such as the cache folder being deleted by some business code, call [remove] and then call [download] to re-download to fix the problem.

Key File Of Example For iOS #

Key File Of Example For Android #

Maintainer: jackleemeta (jackleemeta@outlook.com)

104
likes
0
pub points
85%
popularity

Publisher

unverified uploader

A URL-based flutter downloader that supports to download any type of file and automatically manages a lot of things.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

convert, crypto, flutter, flutter_downloader, path, path_provider

More

Packages that depend on al_downloader