You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.3 KiB

class Product {
final int? id;
final String name;
final double price;
String image;
final String category;
int? stock; // Paramètre optionnel pour le stock
String? description; // Nouveau champ
String? qrCode; // Nouveau champ
String? reference;
Product({
this.id,
required this.name,
required this.price,
required this.image,
required this.category,
this.stock = 0,
this.description,
this.qrCode,
this.reference,
});
// Vérifie si le stock est défini
bool isStockDefined() {
if (stock != null) {
print("stock is defined : $stock $name");
return true;
} else {
return false;
}
}
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
'price': price,
'image': image,
'category': category,
'stock': stock,
'description': description,
'qrCode': qrCode,
'reference':reference
};
}
factory Product.fromMap(Map<String, dynamic> map) {
return Product(
id: map['id'],
name: map['name'],
price: map['price'],
image: map['image'],
category: map['category'],
stock: map['stock'],
description: map['description'],
qrCode: map['qrCode'],
reference:map['reference']
);
}
}