brisk_engine 1.0.1 copy "brisk_engine: ^1.0.1" to clipboard
brisk_engine: ^1.0.1 copied to clipboard

Ultra-fast, highly efficient download engine written in pure dart

example/brisk_engine_example.dart

import 'dart:io';

import 'package:brisk_engine/brisk_engine.dart';

void main() async {
  /// Build the download item either by using this method or manually building it
  /// using HttpDownloadEngine.requestFileInfo(url). Note that buildDownloadItem(url)
  /// automatically uses an isolate to request for file information while requestFileInfo
  /// does so in the same isolate.
  String url =
      "https://github.com/AminBhst/brisk-engine/archive/refs/heads/main.zip";
  final downloadItem = await HttpDownloadEngine.buildDownloadItem(url);

  final settings = DownloadSettings(
    baseSaveDir: Directory("YOUR_BASE_DIRECTORY"),
    totalConnections: 8,
    loggerEnabled: false,
    baseTempDir: Directory("YOUR_BASE_DIRECTORY"),
    connectionRetryTimeoutMillis: 10000,
    maxConnectionRetryCount: -1, // Currently doesn't work
  );

  /// Start the engine
  DownloadEngine.start(
    downloadItem,
    settings,
    onButtonAvailability: (message) {
      /// Handle button availability. A download should only be paused or resumed
      /// when the buttons are available as notified in this method. Otherwise, it could
      /// lead to a corrupted file.
    },
    onDownloadProgress: (message) {
      /// Updates on the download progress will be notified here
    },
  );

  /// You can use the UID which is set on the downloadItem to pause/resume the download

  /// Pause the download
  DownloadEngine.pause(downloadItem.uid);

  /// Resume the download
  DownloadEngine.resume(downloadItem.uid);
}
0
likes
50
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Ultra-fast, highly efficient download engine written in pure dart

Repository (GitHub)

License

MIT (license)

Dependencies

dartx, http, path, path_provider, stream_channel, uuid

More

Packages that depend on brisk_engine