class PantryProduct { final int id; final String name; final String? canonicalName; final String? category; const PantryProduct({ required this.id, required this.name, this.canonicalName, this.category, }); String get displayName { if (canonicalName != null && canonicalName!.trim().isNotEmpty) { return canonicalName!; } return name; } factory PantryProduct.fromJson(Map json) { return PantryProduct( id: (json['id'] as num).toInt(), name: (json['name'] ?? '').toString(), canonicalName: json['canonicalName']?.toString(), category: json['category']?.toString(), ); } }