feat: add pantry management features including repository, providers, and UI integration
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
class PantryItem {
|
||||
final int id;
|
||||
final int productId;
|
||||
final String productName;
|
||||
final String? canonicalName;
|
||||
final String? category;
|
||||
|
||||
const PantryItem({
|
||||
required this.id,
|
||||
required this.productId,
|
||||
required this.productName,
|
||||
this.canonicalName,
|
||||
this.category,
|
||||
});
|
||||
|
||||
String get displayName {
|
||||
if (canonicalName != null && canonicalName!.trim().isNotEmpty) {
|
||||
return canonicalName!;
|
||||
}
|
||||
return productName;
|
||||
}
|
||||
|
||||
factory PantryItem.fromJson(Map<String, dynamic> json) {
|
||||
final product = json['product'] as Map<String, dynamic>? ?? {};
|
||||
return PantryItem(
|
||||
id: (json['id'] as num).toInt(),
|
||||
productId: (json['productId'] as num).toInt(),
|
||||
productName: (product['name'] ?? '').toString(),
|
||||
canonicalName: product['canonicalName']?.toString(),
|
||||
category: product['category']?.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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<String, dynamic> json) {
|
||||
return PantryProduct(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: (json['name'] ?? '').toString(),
|
||||
canonicalName: json['canonicalName']?.toString(),
|
||||
category: json['category']?.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user