From c65832b1905836601336bbca6c6c3548e9327c19 Mon Sep 17 00:00:00 2001 From: Hadi Mottale Date: Fri, 4 Jul 2025 17:02:11 +0330 Subject: [PATCH] Feat: Data Model Added --- lib/models/product.dart | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/models/product.dart 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)'; + } +}