0

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?

fartem
  • 2,361
  • 2
  • 8
  • 20
TiCL
  • 143
  • 6
  • 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
  • 1
    read 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

0 Answers0