feat: add recipe creation, editing, and detail screens; enhance recipe model with instructions and ingredients

This commit is contained in:
Nils-Johan Gynther
2026-04-22 07:53:25 +02:00
parent 2ea18503ef
commit ed4e18dc31
10 changed files with 1017 additions and 44 deletions
@@ -0,0 +1,32 @@
class RecipeIngredient {
final int id;
final int productId;
final String productName;
final double quantity;
final String unit;
final String? note;
const RecipeIngredient({
required this.id,
required this.productId,
required this.productName,
required this.quantity,
required this.unit,
this.note,
});
factory RecipeIngredient.fromJson(Map<String, dynamic> json) {
final product = json['product'] as Map<String, dynamic>?;
final rawQty = json['quantity'];
return RecipeIngredient(
id: (json['id'] as num).toInt(),
productId: (json['productId'] as num).toInt(),
productName: product?['name'] as String? ?? '',
quantity: rawQty is num
? rawQty.toDouble()
: double.tryParse(rawQty?.toString() ?? '') ?? 0,
unit: json['unit'] as String? ?? '',
note: json['note'] as String?,
);
}
}