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
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -191,7 +191,6 @@ class _CreateRecipeScreenState extends ConsumerState<CreateRecipeScreen> {
|
||||
for (var i = 0; i < _parsed!.ingredients.length; i++) {
|
||||
if (!_included[i]) continue;
|
||||
final productId = _selectedProductIds[i];
|
||||
if (productId == null) continue;
|
||||
final qty = double.tryParse(
|
||||
_qtyControllers[i]!.text.trim().replaceAll(',', '.'),
|
||||
) ??
|
||||
@@ -207,9 +206,11 @@ class _CreateRecipeScreenState extends ConsumerState<CreateRecipeScreen> {
|
||||
.toList()
|
||||
: <int>[];
|
||||
ingredients.add({
|
||||
'productId': productId,
|
||||
'quantity': qty,
|
||||
'unit': unit,
|
||||
'rawName': ing.rawName,
|
||||
if ((ing.rawLine ?? '').trim().isNotEmpty) 'rawLine': ing.rawLine,
|
||||
if (productId != null) 'productId': productId,
|
||||
if (qty > 0) 'quantity': qty,
|
||||
if (unit.isNotEmpty) 'unit': unit,
|
||||
if (note.isNotEmpty) 'note': note,
|
||||
if (alternativeProductIds.isNotEmpty)
|
||||
'alternativeProductIds': alternativeProductIds,
|
||||
|
||||
Reference in New Issue
Block a user