Use the parsePhotos() function in the fetchPhotos() function.

4. Move this work to a separate isolate

If you run the fetchPhotos() function on a slower device,
you might notice the app freezes for a brief moment as it parses and
converts the JSON. This is jank, and you want to get rid of it.

You can remove the jank by moving the parsing and conversion
to a background isolate using the compute()
function provided by Flutter. The compute() function runs expensive
functions in a background isolate and returns the result. In this case,
run the parsePhotos() function in the background.

Notes on working with isolates

You might experience errors if you try to pass more complex objects,
such as a Future or http.Response between isolates.

As an alternate solution, check out the worker_manager or
workmanager packages for background processing.

Complete example

Make authenticated requests