Added code property to Ingredient model. Generate ingredient.g.dart.

This commit is contained in:
Adrian Halko
2021-11-22 19:22:59 +01:00
parent 708753a5da
commit 831d74d90d
3 changed files with 12 additions and 2 deletions

View File

@@ -20,7 +20,8 @@ MeasurementEntry _$MeasurementEntryFromJson(Map<String, dynamic> json) {
);
}
Map<String, dynamic> _$MeasurementEntryToJson(MeasurementEntry instance) => <String, dynamic>{
Map<String, dynamic> _$MeasurementEntryToJson(MeasurementEntry instance) =>
<String, dynamic>{
'id': instance.id,
'category': instance.category,
'date': toDate(instance.date),

View File

@@ -25,6 +25,10 @@ class Ingredient {
@JsonKey(required: true)
final int id;
/// Barcode of the product
@JsonKey(required: true)
final String code;
/// Name of the product
@JsonKey(required: true)
final String name;
@@ -66,6 +70,7 @@ class Ingredient {
const Ingredient({
required this.id,
required this.code,
required this.name,
required this.creationDate,
required this.energy,

View File

@@ -11,6 +11,7 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
json,
requiredKeys: const [
'id',
'code',
'name',
'creation_date',
'energy',
@@ -25,6 +26,7 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
);
return Ingredient(
id: json['id'] as int,
code: json['code'] as String,
name: json['name'] as String,
creationDate: DateTime.parse(json['creation_date'] as String),
energy: json['energy'] as int,
@@ -38,8 +40,10 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
);
}
Map<String, dynamic> _$IngredientToJson(Ingredient instance) => <String, dynamic>{
Map<String, dynamic> _$IngredientToJson(Ingredient instance) =>
<String, dynamic>{
'id': instance.id,
'code': instance.code,
'name': instance.name,
'creation_date': toDate(instance.creationDate),
'energy': instance.energy,