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.
 
 
 
 
 
 

63 lines
1.4 KiB

class Product {
int? id;
final String name;
final double price;
final String? image;
final String category;
final int? stock;
final String? description;
String? qrCode;
final String? reference;
final int? pointDeVenteId;
Product({
this.id,
required this.name,
required this.price,
this.image,
required this.category,
this.stock = 0,
this.description = '',
this.qrCode,
this.reference,
this.pointDeVenteId
});
// 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 ?? 0,
'description': description ?? '',
'qrCode': qrCode ?? '',
'reference': reference ?? '',
'point_de_vente_id':pointDeVenteId
};
}
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'],
pointDeVenteId : map['point_de_vente_id']
);
}
}