搜索插件、代码仓与 APP 分类

插件详情v1.8.4

al_downloader

一个基于URL的Flutter下载器,支持下载任何类型的文件,并自动管理许多事项。

AndroidiOS
近 30 天下载
615
喜欢数
104
Pub 分数
120

安装插件

flutter pub add al_downloader

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

al_downloader 是一个 Flutter 包,可在 Android 和 iOS 平台上实现基于 URL 的文件下载。它支持下载任何类型的文件,并自动处理常见的任务,如管理下载队列、跟踪进度以及管理存储权限。该包简化了在 Flutter 应用中实现强大下载功能的过程,非常适合需要可靠后台下载的应用程序。通过 pub add 进行最少的设置,开发者即可轻松集成强大的下载功能。

适合场景

  • 从URL下载文件
  • 后台文件下载
  • 处理大文件传输
  • 管理下载进度
  • 自动下载队列管理

主要特点

  • 支持所有文件类型
  • 自动下载管理
  • 跨平台(Android 和 iOS)
  • 进度跟踪
  • 后台下载支持

适合对象

  • 需要文件下载的应用
  • 媒体内容分发
  • 离线数据缓存
  • 教育或生产力应用
  • 具有大型资产库的应用程序

使用建议

  • Android 需要互联网权限
  • 可能需要在 iOS 上启用后台执行权限
  • 大文件需要仔细的内存管理
  • 文件路径处理可能因平台而异
  • 未提及内置的恢复功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.8.4

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
Initialize
ALDownloader.initialize();
Configure print
ALDownloader.configurePrint(true, frequentEnabled: false);
Download
ALDownloader.download(url,
    directoryPath: directoryPath,
    fileName: fileName,
    handlerInterface:
        ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          'ALDownloader | download progress = $progress, url = $url\n');
    }, succeededHandler: () {
      debugPrint('ALDownloader | download succeeded, url = $url\n');
    }, failedHandler: () {
      debugPrint('ALDownloader | download failed, url = $url\n');
    }, pausedHandler: () {
      debugPrint('ALDownloader | download paused, url = $url\n');
    }));
Add a handler interface
ALDownloader.addHandlerInterface(
    ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          'ALDownloader | download progress = $progress, url = $url\n');
    }, succeededHandler: () {
      debugPrint('ALDownloader | download succeeded, url = $url\n');
    }, failedHandler: () {
      debugPrint('ALDownloader | download failed, url = $url\n');
    }, pausedHandler: () {
      debugPrint('ALDownloader | download paused, url = $url\n');
    }),
    url);
Add a forever handler interface
ALDownloader.addForeverHandlerInterface(
    ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint(
          'ALDownloader | download progress = $progress, url = $url\n');
    }, succeededHandler: () {
      debugPrint('ALDownloader | download succeeded, url = $url\n');
    }, failedHandler: () {
      debugPrint('ALDownloader | download failed, url = $url\n');
    }, pausedHandler: () {
      debugPrint('ALDownloader | download paused, url = $url\n');
    }),
    url);
Remove handler interface
ALDownloader.removeHandlerInterfaceForUrl(url);
Pause download
/// Stop download, but the incomplete data will not be deleted.
ALDownloader.pause(url);
Cancel download
/// Stop download, and the incomplete data will be deleted.
ALDownloader.cancel(url);
Remove download
/// Remove download, and all the data will be deleted.
ALDownloader.remove(url);
Get download status
final status = await ALDownloader.getStatusForUrl(url);
Get download progress
final progress = await ALDownloader.getProgressForUrl(url);
Get task
final task = await ALDownloader.getTaskForUrl(url);
Get all tasks
final tasks = await ALDownloader.tasks;
ALDownloaderBatcher
Batch download
ALDownloaderBatcher.download(urls,
    handlerInterface:
        ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint('ALDownloader | batch | download progress = $progress\n');
    }, succeededHandler: () {
      debugPrint('ALDownloader | batch | download succeeded\n');
    }, failedHandler: () {
      debugPrint('ALDownloader | batch | download failed\n');
    }, pausedHandler: () {
      debugPrint('ALDownloader | batch | download paused\n');
    }));
Add a handler interface for batch
ALDownloaderBatcher.addHandlerInterface(
    ALDownloaderHandlerInterface(progressHandler: (progress) {
      debugPrint('ALDownloader | batch | download progress = $progress\n');
    }, succeededHandler: () {
      debugPrint('ALDownloader | batch | download succeeded\n');
    }, failedHandler: () {
      debugPrint('ALDownloader | batch | download failed\n');
    }, pausedHandler: () {
      debugPrint('ALDownloader | batch | download paused\n');
    }),
    urls);
Get download status for a set of urls
final status = await ALDownloaderBatcher.getStatusForUrls(urls);
Get tasks
final tasks = await ALDownloaderBatcher.getTasksForUrls(urls);
ALDownloaderFileManager - A manager that manages file by url
final physicalFilePath =
    await ALDownloaderFileManager.getPhysicalFilePathForUrl(url);
debugPrint(
    'ALDownloader | get physical file path for [url], url = $url, path = $physicalFilePath\n');

Note:

1. 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 for fixing the problem.

Key File Of Example

iOS
Android

Contributing

Welcome contribution!

Welcome to open issue or PR for any problem, suggestion and idea!

Maintainer: jackleemeta (jackleemeta@outlook.com)

所属分类

依赖

依赖清单 7 项

源码仓库

使用此插件的项目

暂无相关数据。