967121113e
- Implemented inventory screen to display items with details. - Added create, edit, and consume inventory screens for managing items. - Introduced consumption history screen to track item usage. - Created inventory repository and providers for API interactions. - Enhanced routing to include inventory-related paths. - Added necessary models for inventory items and consumption history. - Integrated error handling and loading states for better user experience.
44 lines
1.3 KiB
Dart
44 lines
1.3 KiB
Dart
class InventoryItem {
|
|
final int id;
|
|
final int productId;
|
|
final String productName;
|
|
final double quantity;
|
|
final String unit;
|
|
final String? location;
|
|
final String? brand;
|
|
final String? purchaseDate;
|
|
final String? bestBeforeDate;
|
|
final bool opened;
|
|
final String? comment;
|
|
|
|
const InventoryItem({
|
|
required this.id,
|
|
required this.productId,
|
|
required this.productName,
|
|
required this.quantity,
|
|
required this.unit,
|
|
this.location,
|
|
this.brand,
|
|
this.purchaseDate,
|
|
this.bestBeforeDate,
|
|
required this.opened,
|
|
this.comment,
|
|
});
|
|
|
|
factory InventoryItem.fromJson(Map<String, dynamic> json) {
|
|
return InventoryItem(
|
|
id: json['id'] as int,
|
|
productId: json['productId'] as int,
|
|
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String? ?? '',
|
|
quantity: double.tryParse(json['quantity']?.toString() ?? '0') ?? 0,
|
|
unit: json['unit'] as String? ?? '',
|
|
location: json['location'] as String?,
|
|
brand: json['brand'] as String?,
|
|
purchaseDate: json['purchaseDate'] as String?,
|
|
bestBeforeDate: json['bestBeforeDate'] as String?,
|
|
opened: json['opened'] as bool? ?? false,
|
|
comment: json['comment'] as String?,
|
|
);
|
|
}
|
|
}
|