45 lines
882 B
Dart
45 lines
882 B
Dart
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)';
|
|
}
|
|
}
|