fooder-app/lib/models/diary.dart

35 lines
855 B
Dart
Raw Normal View History

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