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; Product({ this.id, required this.name, required this.price, 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 ?? 0, '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'], ); } }