fetchBytes method

Future<Uint8List> fetchBytes(
  1. String url, {
  2. Map<String, String> headers = const <String, String>{},
  3. void onProgress(
    1. double progress
    )?,
  4. int connections = 1,
})

Silent download into memory. Not listed, not persisted, not resumable across restarts.

Implementation

Future<Uint8List> fetchBytes(
  String url, {
  Map<String, String> headers = const <String, String>{},
  void Function(double progress)? onProgress,
  int connections = 1,
}) async {
  final UDownloadTask task = await enqueue(
    UDownloadRequest(
      url: url,
      headers: headers,
      destination: const UDownloadDestination.memory(),
      visible: false,
      persistent: false,
      priority: UDownloadPriority.high,
      connections: connections,
    ),
  );
  return _await(task, onProgress, (UDownloadTask t) => t.bytes!);
}