Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since the JSON payloads can be quite large, using
json.decode()
on the main thread could cause janking in Flutter.One solution would be to expose a method that does the decoding which defaults to
json.decode
but allow it to be overridden in order to usecompute()
or any otherIsolate
method.I have swapped out all internal package references to
json.decode(response.body)
with
Here's an example of an override using
compute()
:In pure Dart < 2.19 you have to either get creative with the low-level Isolate API or simply import the compute package.
Thankfully, Dart 2.19 will soon come with
Isolate.run()
Another option would also be using a worker pool. The squadron package provides an excellent API and builder just for that purpose.
This addresses #103