fooder-app/lib/models/entry.dart

38 lines
902 B
Dart
Raw Normal View History

2023-07-30 15:31:36 +02:00
import 'package:fooder/models/product.dart';
2023-07-29 19:46:11 +02:00
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;
2023-07-30 20:44:50 +02:00
final double fiber;
2023-07-29 19:21:02 +02:00
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,
2023-07-30 20:44:50 +02:00
required this.fiber,
2023-07-29 19:21:02 +02:00
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,
2023-07-30 20:44:50 +02:00
fiber = map['fiber'] as double,
2023-07-29 23:54:51 +02:00
carb = map['carb'] as double;
2023-07-29 19:21:02 +02:00
}