For this recipe, using the project we built in the previous recipe, we will deal with a real-world JSON file, available at https://github.com/PacktPublishing/Flutter-Cookbook/tree/master/chapter_08. Instead of being perfectly compatible with our class, it will have some inconsistencies and missing fields. This will force us to refactor our code, which will make it more resilient and less error-prone. To do this, follow these steps:
- Delete the content of the pizzalist.json file and paste the content available at https://github.com/PacktPublishing/Flutter-Cookbook/tree/master/chapter_08.
- Run the app. You should get the following error:

- Edit the Pizza.fromJson constructor method in the Pizza.dart file by adding a toString() method to the String values in the method:
Pizza.fromJson(Map<String, dynamic> json) {
this.id = json['id'];
this.pizzaName = json['pizzaName'].toString();
this.description = json['description'].toString...