class Product { String productName; String businessID; String productDesc; String productID; String categoryID; double unitPrice; String productImage; Product( {this.businessID, this.categoryID, this.productDesc, this.productID, this.productImage, this.productName, this.unitPrice}); Product.fromJson(Map json) : businessID = json['businessId'] != null ? json['businessId'].toString() : "....", categoryID = json['category'] != null ? json['category'].toString() : "....", productDesc = json['description'], productID = json['productId'], productImage = json['productImage'], productName = json['name'], unitPrice = double.parse((json['unitPrice']).toString()); Map toJson() { final Map data = Map(); data['businessId'] = this.businessID; data['category'] = this.categoryID; data['description'] = this.productDesc; data['productId'] = this.productID; data['productImage'] = this.productImage; data['name'] = this.productName; data['unitPrice'] = this.unitPrice; return data; } @override String toString() { return '{"businessId": "$businessID","category": "$categoryID", "description": "$productDesc","productId": "$productID",' + '"productImage": "$productImage", "name": "$productName", "unitPrice": "$unitPrice"}'; } }