downloadPdfBytes function

void downloadPdfBytes(
  1. Uint8List bytes,
  2. String filename
)

Trigger a file download in the browser.

Implementation

void downloadPdfBytes(Uint8List bytes, String filename) {
  final blob = html.Blob([bytes], 'application/pdf');
  final url = html.Url.createObjectUrlFromBlob(blob);
  html.AnchorElement(href: url)
    ..setAttribute('download', filename)
    ..click();
  html.Url.revokeObjectUrl(url);
}