feat: add support for alternative ingredients; implement JSON storage and parsing logic
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:
@@ -23,6 +23,7 @@ class ParsedIngredient {
|
||||
final String unit;
|
||||
final String? note;
|
||||
final List<IngredientSuggestion> suggestions;
|
||||
final List<String> alternatives;
|
||||
|
||||
const ParsedIngredient({
|
||||
required this.rawName,
|
||||
@@ -30,6 +31,7 @@ class ParsedIngredient {
|
||||
required this.unit,
|
||||
this.note,
|
||||
required this.suggestions,
|
||||
this.alternatives = const [],
|
||||
});
|
||||
|
||||
factory ParsedIngredient.fromJson(Map<String, dynamic> json) {
|
||||
@@ -42,6 +44,9 @@ class ParsedIngredient {
|
||||
suggestions: rawSuggestions
|
||||
.map((s) => IngredientSuggestion.fromJson(s as Map<String, dynamic>))
|
||||
.toList(),
|
||||
alternatives: (json['alternatives'] as List<dynamic>? ?? [])
|
||||
.map((a) => a as String)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user