Giter Club home page Giter Club logo

flowder's Introduction

Flowder

Handle your file downloads status in a more simple and easy way ๐Ÿ’“

pubspec.yaml

dependencies:

flowder: ^0.2.0

Examples

Basic

To start using flowder, is required to do the following setup.

fina downloaderUtils = DownloaderUtils(

progressCallback: (current, total) {

final progress = (current / total) * 100;

print('Downloading: $progress');

},

file: File('$path_to_store_file/200MB.zip'),

progress: ProgressImplementation(),

onDone: () => print('Download done'),

deleteOnCancel: true,

);

final core = await Flowder.download(

'http://ipv4.download.thinkbroadband.com/200MB.zip',

downloaderUtils);

To start a new download.

core.download(url, downloaderUtils);

To resume a download.

core.resume();

To cancel a download.

core.cancel();

To pause a download.

core.pause();

Advanced

If you require an example using internet connection checker, please go to the folder advanced example. The stack used is:

  • get_it
  • injectable
  • riverpod
  • path_provider
  • connectivity_plus (this is the best plugin to check internet connection, the others were buggy ๐Ÿ˜ข
  • dio.
  • Permission_handler

Currently done:

  • Download states.

  • Handle multiple downloader.

  • Advanced example using internet connection checker.

Contributing

All contributions are welcome!

If you like this project then please click on the ๐ŸŒŸ it'll be appreciated or if you wanna add more epic stuff you can submite your pull request and it'll be gladly accepted ๐Ÿ™†โ€โ™‚๏ธ

or if you have an idea please let me know with a new issue.

flowder's People

Contributors

crdzbird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flowder's Issues

Delete downloaded file

From the documentation there is download and cancel, but is there a way to delete a previously downloaded file rather than having to use File().delete() ?

[Suggestion] Notifications.

Hello @Crdzbird
Thanks for the package.
I would like to suggest few features related to notification that make sense. and I would be happy to work on PR.

  1. Show downloaded progress via notification [using flutter_local_notification].
  2. Once the download is completed show the completed download notification
  3. After download clicking on the notification will open that file.

Let me know what you think.
Feedback is welcome.
Thanks

Null Check Operator

I am building an AAR and Framework that is logic only and has no UI. Instead of the module starting a flutter view, I just call WidgetsFlutterBinding.ensureInitialized(); and then setup a channel. On the native Android side, I warm up the FlutterEngine in the app object as documented by Flutter. When I try to download a file, I get the following error.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
    #0      Flowder.initDownload (package:flowder/src/flowder.dart:54:70)
    <asynchronous suspension>
    #1      Flowder.download (package:flowder/src/flowder.dart:29:28)
    <asynchronous suspension>

Here is my code snippet:

final downloaderUtils = DownloaderUtils(
  progressCallback: (current, total) {
    final progress = (current / total) * 100;
    print('Downloading: $progress');
  },
  file: File('$appDocPath/puppy.jpg'),
  progress: ProgressImplementation(),
  onDone: () => print('Download done'),
  deleteOnCancel: true,
);

final DownloaderCore core = await Flowder.download(
    _FILE_URL,
    downloaderUtils);

Here is my Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel stable, 2.5.2, on macOS 11.5.2 20G95 darwin-x64, locale en-US)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[โœ“] Xcode - develop for iOS and macOS
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 4.1)
[โœ“] VS Code (version 1.53.2)
[โœ“] Connected device (3 available)

โ€ข No issues found!

Support for multiple simultaneous downloads

Hi there,
Thank you for making making Flowder publicly available. I was just wondering if there is any possibility of supporting multiple simultaneous downloads. I am going to use this for a real project.

'VoidCallback' isn't a type

i get this error on build
.
Error: Type 'VoidCallback' not found.
../โ€ฆ/utils/downloader_utils.dart:23
final VoidCallback onDone;
^^^^^^^^^^^^
: Error: 'VoidCallback' isn't a type.
../โ€ฆ/utils/downloader_utils.dart:23
final VoidCallback onDone;
^^^^^^^^^^^^

Re-downloading a file appends to itself instead of overwriting

Hi, when I re-download a file, the file appends to itself instead of overwriting it. For example, if I have an already downloaded file that is 10MB in size and I redownload the file, its size will be 20 MB instead of the same 10 MB. I could use a check to see if the file exists, but the file should still be overwritten instead of appended to itself. Also, if the internet connection fails, the incomplete download does not get deleted.

Here's my code:

if (await InternetConnectionChecker().hasConnection) {
      final downloaderUtils = DownloaderUtils(
        progressCallback: (current, total) async {
          final int progress = ((current / total) * 100).toInt();
          if (progress == 100) {
            await flutterLocalNotificationsPlugin.cancel(123);
          }
        },
        file: File(filePath),
        progress: ProgressImplementation(),
        // ignore: avoid_print
        onDone: () {
          SnackBar downloadFinished = SnackBar(
            content: Text("Finished downloading $itemName"),
            behavior: SnackBarBehavior.floating,
            duration: Duration(seconds: 3),
          );
          ScaffoldMessenger.of(context).showSnackBar(downloadFinished);
        },
        deleteOnCancel: true,
      );
      final core = await Flowder.download(fileUrl, downloaderUtils);

      await flutterLocalNotificationsPlugin.show(123, "Downloading file $itemName, \nplease wait.", "", notificationDetails);
    } else {
      await flutterLocalNotificationsPlugin.cancel(123);
      SnackBar downloadFailed = SnackBar(
        content: Text("Download of $itemName failed. Please try again"),
        behavior: SnackBarBehavior.floating,
        duration: Duration(seconds: 3),
      );
      ScaffoldMessenger.of(context).showSnackBar(downloadFailed);
    }

Set-up authentication for download

Hi,

I need to use flowder to download videos for a mobile application that I am currently developing. Now, the download API requires me to send a Bearer token and "Content-Type": "application/x-www-form-urlencoded" for downloading the video.

I am unable to understand how to set this up in Flowder. Can you please advice me ?

Regards,
Ameya

Firebase Storage download error

When downloading an mp3 from Firebase Storage I get an error code [403] when the download has progressed to about 3-5%. I have to click continue in the debugger for it to continue downloading, which it does and finishes perfectly fine. What's the error code referring to? My internet connection is not an issue when downloading (1gbps download/upload).

Crash

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: Unsupported operation: Functionality only available on Android
#0      MethodChannelPathProvider.getExternalStoragePath (package:path_provider_platform_interface/src/method_channel_path_provider.dart:55:7)
#1      getExternalStorageDirectory (package:path_provider/path_provider.dart:155:40)
#2      _ChatScreenState._buildDocumentMedia.<anonymous closure> (package:txt_vision/screens/chat_screen.dart:697:37)
#3      _ChatScreenState._buildDocumentMedia.<anonymous closure> (package:txt_vision/screens/chat_screen.dart:691:22)
#4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:989:21)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11)
#7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)
#8      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
#9      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
#10     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:443:20)
#11     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
#12     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287:11)
#13     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
#14     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
#15     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
#16     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
#17     _rootRunUnary (dart:async/zone.dart:1370:13)
#18     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#19     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#20     _invoke1 (dart:ui/hooks.dart:182:10)
#21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)

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.