Add new elements to beginning of list

This commit is contained in:
Roland Geider
2020-11-19 18:52:31 +01:00
parent c3aab9c6ad
commit e202eaf1bb
2 changed files with 2 additions and 6 deletions

View File

@@ -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);

View File

@@ -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;
}
}