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 toMap() { return { 'id': id, 'name': name, 'price': price, 'image': image, 'category': category, 'stock': stock, 'description': description, 'qrCode': qrCode, 'reference':reference }; } factory Product.fromMap(Map 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'] ); } }