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

GitHub 代码仓nabil6391/flutter_download_manager

flutter_download_manager

Flutter 下载管理器是一个跨平台文件下载器,支持可恢复、并行和批量下载。还可以接收下载状态和进度更新的通知

flutter_download_manager 项目封面
星标
52
复刻
34
最近推送(UTC)
2024年6月7日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Flutter Download Manager

pub package pub points popularity likes |

Overview

Flutter Download Manager is a Cross-Platform file downloader with Parallel and Batch Download support. Manage download tasks by url and be notified of status and their progress. Pause, Cancel, Queue and Resume Downloads.

This package was made as I felt like there are no download managers in flutter, specially with desktop support.

alt Example

Features

  • Manage download tasks by url
  • Ability to notified of status and progress changes
  • Partial Download Feature
  • Queue Downloads
  • Pause, Cancel or Resume Downloads
  • Parallel File Downloads (2 or can change)
  • Support Batch download

Platforms Supported

  • Linux
  • MacOS
  • Windows
  • Android
  • iOS

There are a few caveats about this package:

  • On desktop it saves the file in absolute or relative path.
  • On mobile it saves the file in absolute or relative path, but we should ask/ensure if the app has the required permissions.
  • It does not run in a background process, so when the dart application closes the manager will also shut down.

Getting Started

In your pubspec.yaml file add:

dependencies:
  flutter_download_manager: any

Then, in your code import:

import 'package:flutter_download_manager/flutter_download_manager.dart';

Usage

Please refer to /example folder for a working example.

Simply Download a file
var dl = DownloadManager();
var url = "adasdad.com/asda.sdas";
await dl.addDownload(url, "./test.sdas");

DownloadTask? task = dl.getDownload(url4);

task?.status.addListener(() {
  print(task.status.value);
});

task?.progress.addListener(() {
  print(task.progress.value);
});

await dl.whenDownloadComplete(url4);
Get Download Status
DownloadTask? task = dl.getDownload(url4);

task?.status.addListener(() {
  print(task.status.value);
});
Get Download Progress
DownloadTask? task = dl.getDownload(url4);

task?.progress.addListener(() {
  print(task.progress.value);
});
Await for a task to be complete
DownloadTask? task = dl.getDownload(url4);

await task.whenDownloadComplete();
Cancel a task
var dl = DownloadManager();

dl.cancelDownload(url5);
Pause a task
var dl = DownloadManager();

dl.pauseDownload(url5);
Resume a task
var dl = DownloadManager();

dl.resumeDownload(url5);
Download in Batch
var dl = DownloadManager();

var urls = <String>[];
urls.add(url2);
urls.add(url3);
urls.add(url);

await dl.addDownload(url2, "./test2.ipa");
await dl.addDownload(url3, "./test3.ipa");
await dl.addDownload(url, "./test.ipa");

var downloadProgress = dl.getDownloadProgress(urls);

downloadProgress.addListener(() {
  print(downloadProgress.value);
});

await dl.whenDownloadsComplete(urls);
var dl = DownloadManager();

var urls = <String>[];
urls.add(url2);
urls.add(url3);
urls.add(url);

dl.addBatchDownloads(urls, "./");
Cancel a Batch Download
var dl = DownloadManager();

var urls = <String>[];
urls.add(url6);
urls.add(url5);
urls.add(url);

dl.cancelDownloads(urls);
Get Batch Download Progress
var dl = DownloadManager();

var urls = <String>[];
urls.add(url2);
urls.add(url3);

var downloadProgress = dl.getDownloadProgress(urls);

downloadProgress.addListener(() {
  print(downloadProgress.value);
});
Await for Batch Download to complete
var dl = DownloadManager();

var urls = <String>[];
urls.add(url2);
urls.add(url3);
urls.add(url);

await dl.whenDownloadsComplete(urls);

Future Work

[] Add in Shared Preference to survive app shutdown

DownloadStatus

enum DownloadStatus { queued, downloading, completed, failed, paused, canceled }

Nabil Mosharraf GitHub avatar
GitHub 作者

Nabil Mosharraf ↗

Product-focused tech lead building mobile solutions that serve millions. Creator of GraphView & Al-Quran (2M+ MAU)

SeekKuala Lampur
语言DartC++CMakeRubyCSwiftKotlinObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 5 项

  • flutter{"sdk":"flutter"}
  • dio^5.0.2
  • collection—
  • flutter_test开发依赖{"sdk":"flutter"}
  • lints开发依赖^2.0.1

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗