How do I unload an event loop in Dart? It is quite a common situation for us to have APIs like Future<List<T>>.
Imagine a method that returns a list of users. What you do there is parse the json into a dart list and then somehow convert it into a typed list of models. This conversion to models can be done lazily. Just change the API to Stream<T> and you will get the idea. You can put all the elements in the event loop to process them asynchronously.
Here is the link to the working flutter app, which gives you an example of how to do this:
https://gist.github.com/hawkkiller/932140079adfdcab2cfdd4b0292bb50a
#dart #flutter #async #eventloop #tip
Imagine a method that returns a list of users. What you do there is parse the json into a dart list and then somehow convert it into a typed list of models. This conversion to models can be done lazily. Just change the API to Stream<T> and you will get the idea. You can put all the elements in the event loop to process them asynchronously.
Here is the link to the working flutter app, which gives you an example of how to do this:
https://gist.github.com/hawkkiller/932140079adfdcab2cfdd4b0292bb50a
#dart #flutter #async #eventloop #tip
Gist
Event Loop unloading
Event Loop unloading. GitHub Gist: instantly share code, notes, and snippets.