hyper_thread_downloader 1.0.5+3 copy "hyper_thread_downloader: ^1.0.5+3" to clipboard
hyper_thread_downloader: ^1.0.5+3 copied to clipboard

A Hyper Thread Downloader work with Dio packages.

example/hyper_thread_downloader_example.dart

import 'dart:io';

import 'package:hyper_thread_downloader/hyper_thread_downloader.dart';
import 'package:hyper_thread_downloader/src/util/log_util.dart';
import 'package:hyper_thread_downloader/src/util/string_util.dart';

void main() async {
  final md = HyperDownload();
  int taskId = -1;
  final url =
      'https://updates.cdn-apple.com/2023WinterFCS/fullrestores/032-73564/23D75440-B300-4932-8BD7-283C6218FF4E/iPhone_4.7_15.7.6_19H349_Restore.ipsw';
  await md.startDownload(
      url: url,
      savePath: '/Users/cj/Desktop/cache/${url.getDropLastWhile(Platform.pathSeparator)}',
      threadCount: Platform.numberOfProcessors,
      fileSize: 5000000,
      downloadProgress: ({
        required double progress,
        required double speed,
        required double remainTime,
        required int count,
        required int total,
      }) {
        HyperLog.log('download progress: $progress, speed: $speed');
      },
      downloadComplete: () {
        HyperLog.log('download complete');
      },
      downloadFailed: (String reason) {
        HyperLog.log('download failed');
      },
      downloadTaskId: (int id) {
        print('start task id: $id');
        taskId = id;
      },
      workingMerge: (bool ret) {
        HyperLog.log('working merge: $ret');
      },
      downloadingLog: (String log) {},
      prepareWorking: (bool value) {});

  stdin.listen(
    (event) {
      String e = String.fromCharCodes(event);
      if (e.contains('stop')) {
        md.stopDownload(id: taskId);
      } else if (e.contains('start')) {
        md.startDownload(
            url: url,
            savePath: '/Users/cj/Desktop/cache/${url.getDropLastWhile('/')}',
            threadCount: Platform.numberOfProcessors,
            downloadProgress: ({
              required double progress,
              required double speed,
              required double remainTime,
              required int count,
              required int total,
            }) {},
            downloadComplete: () {},
            downloadFailed: (String reason) {},
            downloadTaskId: (int id) {
              print('start task id: $id');
              taskId = id;
            },
            workingMerge: (bool ret) {},
            downloadingLog: (String log) {},
            prepareWorking: (bool value) {});
      }
    },
  );
}
3
likes
110
pub points
75%
popularity

Publisher

unverified uploader

A Hyper Thread Downloader work with Dio packages.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

dio

More

Packages that depend on hyper_thread_downloader