simple_file_downloader_flutter 0.0.1 copy "simple_file_downloader_flutter: ^0.0.1" to clipboard
simple_file_downloader_flutter: ^0.0.1 copied to clipboard

a simple file downloader by dio, support resume from breakpoint

flutter version of Simple file downloader

Features #

  • pure dart
  • support resume from breakpoint
  • support progress and speed callback

Getting started #

Usage #

  //init
  //open log , close default
  FileDownloader.openLog = true;
  //custom your dio . not necessary.
  //FileDownloader.dio = Dio();

  //default download save dir, must be set if not set filePath when download
  FileDownloader.globalSaveDir = "/Users/hss/Downloads";



  var url = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WeAreGoingOnBullrun.mp4";
 FileDownloader(
    url: url,
    //filePath: "/Users/hss/Downloads/WeAreGoingOnBullrun-2.mp4",
    onSuccess: (url, filePath) {
      //print('下载成功: $url -> $filePath');
    },
  ).start();

 //cancel download
 Future.delayed(Duration(seconds: 3)).then((value) => FileDownloader.cancel(url));

the fileDownloader support configs:

  FileDownloader({
    required this.url,
    this.filePath,
    this.forceRedownload,
    this.notAcceptRanges,
    this.headers = const {},
    this.fileSizeAlreadyKnown,
    this.onStartReal,
    this.onFailed,
    this.progressCallbackIntervalMills = 300,
    this.retryTimes = 1,
    this.tags = const {},
    required this.onSuccess,
    this.onProgress,
    this.onCancel,
  });

some case #

file already downloaded: #

image-20240906100706137

reqeust started then canceled when downloading: #

image-20240906100913113

resume downloading from breakpoint #

image-20240906101036223

And finally download success:

image-20240906101100940

a response without content-length: #

image-20240906101827962

Additional information #

1
likes
100
pub points
0%
popularity

Publisher

verified publisherhss01248.tech

a simple file downloader by dio, support resume from breakpoint

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dio, dio_http_formatter, flutter

More

Packages that depend on simple_file_downloader_flutter