class Discount { final int discountid; final String discountname; final String discountcode; final String discountterms; final double discountvalue; Discount({ required this.discountid, required this.discountname, required this.discountcode, required this.discountterms, required this.discountvalue, }); factory Discount.fromJson(Map json) { return Discount( discountid: json['discountid'], discountname: json['discountname'], discountcode: json['discountcode'], discountterms: json['discountterms'], discountvalue: (json['discountvalue'] ?? 0).toDouble(), ); } }