Refactor blob creation in file download to enhance readability

This commit is contained in:
Leon Bösche
2026-01-13 23:16:25 +01:00
parent bc9c7a06c8
commit 744fbf87f5

View File

@@ -354,7 +354,9 @@ class _FileExplorerState extends State<FileExplorer> {
final bytes = response.bodyBytes;
final blob = web.Blob(
[bytes.toJS].toJS,
web.BlobPropertyBag(type: response.headers['content-type'] ?? 'application/octet-stream'),
web.BlobPropertyBag(
type: response.headers['content-type'] ?? 'application/octet-stream',
),
);
final blobUrl = web.URL.createObjectURL(blob);
@@ -365,7 +367,7 @@ class _FileExplorerState extends State<FileExplorer> {
..style.display = 'none';
web.document.body?.appendChild(anchor);
anchor.click();
// Cleanup
web.document.body?.removeChild(anchor);
web.URL.revokeObjectURL(blobUrl);