hpoul / file_picker_writable

Flutter plugin to choose files which can be read, referenced and written back at a later time.
https://pub.dev/packages/file_picker_writable
MIT License
17 stars 13 forks source link

Await result in readFile #10

Closed amake closed 4 years ago

amake commented 4 years ago

I updated to the latest API changes and found that the FileReader is not awaited in the readFile method, so in my application the file was always deleted before it could be read.

(By the way you were right, the changes were not as hard to deal with as I thought they would be.)

hpoul commented 4 years ago

thanks, good catch.. I wonder why I didn't stumble on that 🤔️ maybe readAsBytes synchronously creates a file handle on that file (ie. open), and only reads asynchronously?

did you do some other async action in the callback before reading?

amake commented 4 years ago

did you do some other async action in the callback before reading?

Yes, the part in my FileReader that actually reads the file is a separate async function because I need to detect the encoding if the file is not UTF-8.

hpoul commented 4 years ago

Okay that makes perfect sense, at least now i don't have to rush another bug fix release for AuthPass 😅 should still be stable as long as I've got a file handle synchronously