Parse JSON in the background
import 'dart:async' ; import 'dart:convert' ; import 'package:flutter/foundation.dart' ; import 'package:flutter/material.dart' ; import 'package:http/http.dart' as http ; Future < List < Photo >> fetchPhotos ( http . Client client ) async { final response = await client . get ( 'https://jsonplaceholder.typicode.com/photos' ); // Use the compute function to run parsePhotos in a separate isolate. return compute ( parsePhotos , response . body ); } // A function that converts a response body into a List<Photo>. List < Photo > parsePhotos ( String responseBody ) { final parsed = json . decode ( responseBody ). cast < Map < String , dynamic >>(); return parsed . map < Photo >(( json ) => Photo . fromJson ( json )). toList (); } class Photo { final int albumId ; final int id ; final String title ; final String ur...