2023-07-29 19:21:02 +02:00
|
|
|
import 'package:fooder_web/models/meal.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class Diary {
|
2023-07-29 20:55:32 +02:00
|
|
|
final int id;
|
|
|
|
final DateTime date;
|
2023-07-29 19:21:02 +02:00
|
|
|
final List<Meal> meals;
|
2023-07-29 20:55:32 +02:00
|
|
|
final double calories;
|
|
|
|
final double protein;
|
|
|
|
final double carb;
|
|
|
|
final double fat;
|
2023-07-29 19:21:02 +02:00
|
|
|
|
2023-07-29 20:55:32 +02:00
|
|
|
Diary({
|
|
|
|
required this.id,
|
|
|
|
required this.date,
|
2023-07-29 19:21:02 +02:00
|
|
|
required this.meals,
|
2023-07-29 20:55:32 +02:00
|
|
|
required this.calories,
|
|
|
|
required this.protein,
|
|
|
|
required this.carb,
|
|
|
|
required this.fat,
|
2023-07-29 19:21:02 +02:00
|
|
|
});
|
2023-07-29 20:55:32 +02:00
|
|
|
|
|
|
|
Diary.fromJson(Map<String, dynamic> map):
|
|
|
|
id = map['id'] as int,
|
|
|
|
date = DateTime.parse(map['date']),
|
2023-07-29 23:54:51 +02:00
|
|
|
meals = (map['meals'] as List<dynamic>).map((e) => Meal.fromJson(e as Map<String, dynamic>)).toList(),
|
2023-07-29 20:55:32 +02:00
|
|
|
calories = map['calories'] as double,
|
|
|
|
protein = map['protein'] as double,
|
|
|
|
carb = map['carb'] as double,
|
|
|
|
fat = map['fat'] as double;
|
2023-07-29 19:21:02 +02:00
|
|
|
}
|