Fix URL to add meals

This commit is contained in:
Roland Geider
2021-01-24 20:07:03 +01:00
parent 192094399a
commit ae003b0cdb
3 changed files with 4 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ part 'meal.g.dart';
@JsonSerializable()
class Meal {
@JsonKey(required: true)
@JsonKey(required: false)
final int id;
@JsonKey(required: false)
@@ -36,7 +36,7 @@ class Meal {
@JsonKey(required: true, toJson: timeToString, fromJson: stringToTime)
TimeOfDay time;
@JsonKey(name: 'meal_items', defaultValue: [])
@JsonKey(required: false, name: 'meal_items', defaultValue: [])
List<MealItem> mealItems = [];
Meal({

View File

@@ -7,7 +7,7 @@ part of 'meal.dart';
// **************************************************************************
Meal _$MealFromJson(Map<String, dynamic> json) {
$checkKeys(json, requiredKeys: const ['id', 'time']);
$checkKeys(json, requiredKeys: const ['time']);
return Meal(
id: json['id'] as int,
plan: json['plan'] as int,

View File

@@ -128,7 +128,7 @@ class Nutrition extends WgerBaseProvider with ChangeNotifier {
/// Adds a meal to a plan
Future<Meal> addMeal(Meal meal, int planId) async {
var plan = findById(planId);
final data = await post(meal.toJson(), _mealPath);
final data = await post(meal.toJson(), makeUrl(_mealPath));
meal = Meal.fromJson(data);
plan.meals.add(meal);