feat: enhance recipe ingredient model; add raw fields and optional properties for better ingredient handling
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-06 07:25:42 +02:00
parent 612fcddb47
commit e4f201ea36
9 changed files with 349 additions and 267 deletions
@@ -1,15 +1,19 @@
class RecipeIngredient {
final int id;
final int productId;
final String productName;
final int? productId;
final String? productName;
final String rawName;
final String? rawLine;
final double quantity;
final String unit;
final String? note;
const RecipeIngredient({
required this.id,
required this.productId,
required this.productName,
this.productId,
this.productName,
required this.rawName,
this.rawLine,
required this.quantity,
required this.unit,
this.note,
@@ -20,8 +24,10 @@ class RecipeIngredient {
final rawQty = json['quantity'];
return RecipeIngredient(
id: (json['id'] as num).toInt(),
productId: (json['productId'] as num).toInt(),
productName: product?['name'] as String? ?? '',
productId: (json['productId'] as num?)?.toInt(),
productName: product?['canonicalName'] as String? ?? product?['name'] as String?,
rawName: json['rawName'] as String? ?? '',
rawLine: json['rawLine'] as String?,
quantity: rawQty is num
? rawQty.toDouble()
: double.tryParse(rawQty?.toString() ?? '') ?? 0,