downloadContent function

Future<Uint8List> downloadContent(
  1. String url, {
  2. Duration expiration = const Duration(days: 365),
  3. String? filename,
  4. String? dirPath,
  5. Function? onDownloadBegin,
  6. Function? onDownloadEnd,
  7. Function? onDownloadProgress,
})

Implementation

Future<Uint8List> downloadContent(
  String url, {
  Duration expiration = const Duration(days: 365),
  String? filename,
  String? dirPath,
  Function? onDownloadBegin,
  Function? onDownloadEnd,
  Function? onDownloadProgress,
}) async {
  final path = await download(
    url,
    expiration: expiration,
    filename: filename,
    dirPath: dirPath,
    onDownloadBegin: onDownloadBegin,
    onDownloadEnd: onDownloadEnd,
    onDownloadProgress: onDownloadProgress,
  );

  /// Read the file
  final file = File(path);

  /// Return the content of the file.
  return await file.readAsBytes();
}