incrediblezayed / file_saver

A simple flutter plugin for saving files in all platforms
https://pub.dev/packages/file_saver
BSD 3-Clause "New" or "Revised" License
75 stars 92 forks source link

Fix crashes when saving files from a file source #74

Closed Silfalion closed 8 months ago

Silfalion commented 10 months ago

Hey @incrediblezayed sorry for the delay, I added changes but they feel quite rough, this is just the initial logic since I didn't want to change too much without your feedback.

Ideally, I think sealed classes FileMode.byte and FileMode.file would allow the logic to be "buried" more inside the Platform handler and keep the surface code cleaner. This would need a Dart 3.0 upgrade. If you're up for that, I can make another pull request that we can merge later into this one.

Silfalion commented 10 months ago

These are the results with and without the logic.

Screenshot from 2023-09-03 10-16-34 Screenshot from 2023-09-03 10-16-52

I used a file of size 1.1 Gb, The in-memory bytes are freed after a bit of time, but with this file size, it will be fatal regardless.

Silfalion commented 10 months ago

To better test it, I added a separation for testing bytes and file savings in the example folder. Hope that's alright.

incrediblezayed commented 10 months ago

Hey, @Silfalion, I'll check it, test it and merge asap

Silfalion commented 10 months ago

Thank you:)