barely functional database with hive
This commit is contained in:
@@ -11,6 +11,18 @@ class Ingredient {
|
||||
this.preferredBrands = const [],
|
||||
});
|
||||
|
||||
factory Ingredient.fromJson(Map<String, dynamic> json) => Ingredient(
|
||||
title: json['title'] as String,
|
||||
possibleUnits: _unitsFromJson(json['possibleUnits']),
|
||||
preferredBrands: json['preferredBrands'] as List<String>,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'title': title,
|
||||
'possibleUnits': possibleUnits.map((e) => e.toJson()).toList(),
|
||||
'preferredBrands': preferredBrands,
|
||||
};
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
Ingredient i = other as Ingredient;
|
||||
@@ -21,4 +33,7 @@ class Ingredient {
|
||||
int get hashCode {
|
||||
return Object.hash(title, null);
|
||||
}
|
||||
|
||||
static List<Unit> _unitsFromJson(List<Map<String, dynamic>> jsonList) =>
|
||||
jsonList.map((e) => Unit.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user