Feat: Data Model Added
This commit is contained in:
parent
853d7ef0b8
commit
c65832b190
|
@ -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<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'code': code,
|
||||
'quantity': quantity,
|
||||
'price': price,
|
||||
'description': description,
|
||||
};
|
||||
}
|
||||
|
||||
factory Product.fromMap(Map<String, dynamic> 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)';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue