class Discount { String id; String code; String customerId; String customerName; String status; double amount; Discount({ this.id, this.code, this.customerId, this.customerName, this.amount, this.status, }); Map toMap() { return { 'id': id, 'code': code, "customer_id": customerId, "customer_name": customerName, "amount": amount, }; } factory Discount.fromMap(Map map, String id) { return Discount( id: id, code: map['code'], customerId: map['customer_id'], customerName: map['customer_name'], amount: map['amount'], status: map['status'], ); } bool isChangedForEdit(Discount discount) { return discount.code != this.code || discount.amount != this.amount || discount.customerId != this.customerId; } }