class Desire { String productName; String productID; String productImage; String enlisted; double price; String category; Desire( {this.productName, this.enlisted, this.productID, this.productImage, this.price, this.category}); factory Desire.fromJSON(Map json) { return Desire( productID: json["productID"], productName: json["productName"], productImage: json["productImage"], enlisted: json["enlisted"], category: json["category"], price: double.tryParse(json["cost"].toString())); } Map toJson() { final Map data = Map(); data['productID'] = this.productID; data['productName'] = this.productName; data['enlisted'] = this.enlisted; data['productImage'] = this.productImage; data['cost'] = this.price; data['category'] = this.category; return data; } @override String toString() { return '{"productID": "$productID", "productName": "$productName", "enlisted": "$enlisted","productImage":"$productImage","cost":"$price","category":"$category"}'; } }