import 'package:fooder/models/product.dart'; class Entry { final int id; final double grams; final Product product; final int mealId; final double calories; final double protein; final double fat; final double fiber; final double carb; Entry({ required this.id, required this.grams, required this.product, required this.mealId, required this.calories, required this.protein, required this.fat, required this.fiber, required this.carb, }); Entry.fromJson(Map map) : id = map['id'] as int, grams = map['grams'] as double, product = Product.fromJson(map['product'] as Map), mealId = map['meal_id'] as int, calories = map['calories'] as double, protein = map['protein'] as double, fat = map['fat'] as double, fiber = map['fiber'] as double, carb = map['carb'] as double; Map toMap() { return { 'id': id, 'grams': grams, 'product': product.toMap(), 'mealId': mealId, 'calories': calories, 'protein': protein, 'fat': fat, 'fiber': fiber, 'carb': carb, }; } }