class Category { String name; String color; Category({this.name, 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( {this.amount, this.description, this.date, this.name, this.category}); Transaction.fromJson(Map map) : category = Category.formJson(map["category"]), amount = map["amount"], description = map["description"], name = map["name"], date = map["date"]; }