I need to process files on onPressed event of a button. I see that functions like readAsBytes and length has sync and async variants. Which ones should I use for such processing?
Asked
Active
Viewed 187 times
0
-
Use async. Because this will be the most preferred method. Since if it you are reading a large file then the app will be stalled for a considerable amount of time if you use synchrous process – Adithya Shetty Jan 29 '21 at 05:33
-
1read this: https://stackoverflow.com/a/61420070/8097519 – Aakash kondhalkar Jan 29 '21 at 05:34
-
most likely, instead of calling `readAsBytes` (which reads the entire file contents as a list of bytes) you should use `File.openRead` and process your data by means of `Stream`s (unless your files are couple of kB in size of course) – pskink Jan 29 '21 at 05:51