Refactor blob creation in file download to enhance readability
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user