diff --git a/lib/models/product.dart b/lib/models/product.dart new file mode 100644 index 0000000..0e9b498 --- /dev/null +++ b/lib/models/product.dart @@ -0,0 +1,44 @@ +class Product { + int? id; + String name; + String code; + int quantity; + double price; + String? description; + + Product({ + this.id, + required this.name, + required this.code, + required this.quantity, + required this.price, + this.description, + }); + + Map toMap() { + return { + 'id': id, + 'name': name, + 'code': code, + 'quantity': quantity, + 'price': price, + 'description': description, + }; + } + + factory Product.fromMap(Map map) { + return Product( + id: map['id'], + name: map['name'], + code: map['code'], + quantity: map['quantity'], + price: map['price'], + description: map['description'], + ); + } + + @override + String toString() { + return 'Product(id: $id, name: $name, code: $code, quantity: $quantity, price: $price, description: $description)'; + } +}