mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Fix URL to add meals
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user