class Category { String name; String color; Category({required this.name, required this.color}); Category.formJson(Map map) : name = map["name"], color = map["color"]; } class Transaction { String amount; String description; String date; String name; Category category; Transaction( {required this.amount, required this.description, required this.date, required this.name, required this.category}); Transaction.fromJson(Map map) : category = Category.formJson(map["category"]), amount = map["amount"], description = map["description"], name = map["name"], date = map["date"]; }