From e202eaf1bbca170dcaa6026c1df27ea3cb14661b Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 19 Nov 2020 18:52:31 +0100 Subject: [PATCH] Add new elements to beginning of list --- lib/providers/nutritional_plans.dart | 2 +- lib/providers/workout_plans.dart | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/providers/nutritional_plans.dart b/lib/providers/nutritional_plans.dart index a612eaab..44d7b9f6 100644 --- a/lib/providers/nutritional_plans.dart +++ b/lib/providers/nutritional_plans.dart @@ -62,7 +62,7 @@ class NutritionalPlans with ChangeNotifier { ); print(plan.toJson()); print(json.decode(response.body)); - _entries.add(NutritionalPlan.fromJson(json.decode(response.body))); + _entries.insert(0, NutritionalPlan.fromJson(json.decode(response.body))); notifyListeners(); } catch (error) { print(error); diff --git a/lib/providers/workout_plans.dart b/lib/providers/workout_plans.dart index 6afd3f31..1572292a 100644 --- a/lib/providers/workout_plans.dart +++ b/lib/providers/workout_plans.dart @@ -150,13 +150,9 @@ class WorkoutPlans with ChangeNotifier { }, body: json.encode(workout.toJson()), ); - print(workout.toJson()); - print(json.decode(response.body)); - final newWorkout = WorkoutPlan.fromJson(json.decode(response.body)); - _entries.add(newWorkout); + _entries.insert(0, WorkoutPlan.fromJson(json.decode(response.body))); notifyListeners(); } catch (error) { - print(error); throw error; } }