GithubHelp home page GithubHelp logo

ortolanph / flutter_download_manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nabil6391/flutter_download_manager

0.0 1.0 0.0 557 KB

Flutter Download Manager is a Cross-Platform file downloader with resumeable, parallel and batch Download support. Also be notified of download status and progress updates

License: MIT License

Ruby 3.34% C++ 26.05% C 1.77% Objective-C 0.05% Kotlin 0.15% Dart 43.78% Swift 1.59% CMake 23.26%

flutter_download_manager's Introduction

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";
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);

dl.addDownload(url2, "./test2.ipa");
dl.addDownload(url3, "./test3.ipa");
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 }

flutter_download_manager's People

Contributors

nabil6391 avatar ortolanph avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.