fooder-app/lib/models/entry.dart

35 lines
823 B
Dart
Raw Normal View History

2023-07-29 19:46:11 +02:00
import 'package:fooder_web/models/product.dart';
2023-07-29 19:21:02 +02:00
class Entry {
2023-07-29 19:46:11 +02:00
final int id;
final double grams;
final Product product;
final int mealId;
2023-07-29 19:21:02 +02:00
final double calories;
final double protein;
final double fat;
final double carb;
2023-07-29 20:55:32 +02:00
Entry({
2023-07-29 19:46:11 +02:00
required this.id,
required this.grams,
required this.product,
required this.mealId,
2023-07-29 19:21:02 +02:00
required this.calories,
required this.protein,
required this.fat,
required this.carb,
});
2023-07-29 23:54:51 +02:00
Entry.fromJson(Map<String, dynamic> map):
id = map['id'] as int,
grams = map['grams'] as double,
product = Product.fromJson(map['product'] as Map<String, dynamic>),
mealId = map['meal_id'] as int,
calories = map['calories'] as double,
protein = map['protein'] as double,
fat = map['fat'] as double,
carb = map['carb'] as double;
2023-07-29 19:21:02 +02:00
}