barely functional database with hive

This commit is contained in:
SomnusVeritas
2023-11-06 18:19:52 +01:00
parent da4dc83193
commit d1da474998
9 changed files with 114 additions and 5 deletions

View File

@@ -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();
}