In this recipe, we transformed the Map objects into Pizza objects. To do this, we created a constructor in the Pizza class that takes a Map<String, dynamic> and, from that, creates a new Pizza object:
Pizza.fromJson(Map<String, dynamic> json) {
this.id = json['id'];
this.pizzaName = json['pizzaName'];
this.description = json['description'];
this.price = json['price'];
this.imageUrl = json['imageUrl'];
}
The interesting part of this method is how you access the values of the map; that is, using square brackets and the name of the key (for example, json['pizzaName'] takes the name of Pizza).
When this named constructor has finished executing, you get a Pizza object that's ready to be used in your app.