import 'dart:convert'; class RecipeResponse { RecipeResponse({ required this.data, }); List data; factory RecipeResponse.fromJson(Map json) => RecipeResponse( data: List.from(json["data"].map((x) => Recipe.fromJson(x))), ); Map toJson() => { "data": List.from(data.map((x) => x.toJson())), }; } class Recipe { int id; String title; String imageUrl; String difficulty; String sourceUrl; int calories; int completenessPercentage; bool isFavorited; Rating rating; Recipe({ required this.id, required this.title, required this.imageUrl, required this.difficulty, required this.sourceUrl, required this.calories, required this.completenessPercentage, required this.isFavorited, required this.rating, }); factory Recipe.fromJson(Map json) => Recipe( id: json["id"], title: json["title"], imageUrl: json["image_url"], difficulty: json["difficulty"], sourceUrl: json["source_url"], calories: json["calories"], completenessPercentage: json["completeness_percentage"], isFavorited: json["is_favorited"], rating: Rating.fromJson(json["rating"]), ); Map toJson() => { "id": id, "title": title, "image_url": imageUrl, "difficulty": difficulty, "source_url": sourceUrl, "calories": calories, "completeness_percentage": completenessPercentage, "is_favorited": isFavorited, "rating": rating.toJson(), }; } class Rating { double score; int amount; Rating({ required this.score, required this.amount, }); factory Rating.fromJson(Map json) => Rating( score: json["score"], amount: json["amount"], ); Map toJson() => { "score": score, "amount": amount, }; }