class Product { final int? id; final String name; final double unitPrice; final double discount; Product({ this.id, required this.name, required this.unitPrice, required this.discount, }); Map toMap() { return { 'id': id, 'name': name, 'unit_price': unitPrice, 'discount': discount, }; } factory Product.fromMap(Map map) { return Product( id: map['id'] as int?, name: map['name'] as String, unitPrice: map['unit_price'] as double, discount: map['discount'] as double, ); } }