fooder-app/lib/models/meal.dart

42 lines
1.1 KiB
Dart
Raw Normal View History

2023-07-30 15:31:36 +02:00
import 'package:fooder/models/entry.dart';
2023-07-29 19:21:02 +02:00
class Meal {
final List<Entry> entries;
2023-07-29 23:54:51 +02:00
final int id;
final String name;
final int order;
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 23:54:51 +02:00
final int diaryId;
2023-07-29 19:21:02 +02:00
2023-07-29 23:54:51 +02:00
Meal({
2023-07-29 19:21:02 +02:00
required this.entries,
2023-07-29 23:54:51 +02:00
required this.id,
required this.name,
required this.order,
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 23:54:51 +02:00
required this.diaryId,
2023-07-29 19:21:02 +02:00
});
2023-07-29 23:54:51 +02:00
2023-08-28 14:45:32 +02:00
Meal.fromJson(Map<String, dynamic> map)
: entries = (map['entries'] as List<dynamic>)
.map((e) => Entry.fromJson(e as Map<String, dynamic>))
.toList(),
id = map['id'] as int,
name = map['name'] as String,
order = map['order'] as int,
calories = map['calories'] as double,
protein = map['protein'] as double,
carb = map['carb'] as double,
fat = map['fat'] as double,
fiber = map['fiber'] as double,
diaryId = map['diary_id'] as int;
2023-07-29 19:21:02 +02:00
}