@@ -83,6 +83,15 @@ class RoutinesProvider with ChangeNotifier {
83
83
_repetitionUnits = repetitionUnits ?? [];
84
84
}
85
85
86
+ /// Returns the current active nutritional plan. At the moment this is just
87
+ /// the latest, but this might change in the future.
88
+ Routine ? get currentRoutine {
89
+ if (_routines.isNotEmpty) {
90
+ return _routines.first;
91
+ }
92
+ return null ;
93
+ }
94
+
86
95
List <Routine > get items {
87
96
return [..._routines];
88
97
}
@@ -97,7 +106,6 @@ class RoutinesProvider with ChangeNotifier {
97
106
98
107
/// Clears all lists
99
108
void clear () {
100
- activeRoutine = null ;
101
109
_routines = [];
102
110
_weightUnits = [];
103
111
_repetitionUnits = [];
@@ -138,16 +146,6 @@ class RoutinesProvider with ChangeNotifier {
138
146
return _routines.indexWhere ((routine) => routine.id == id);
139
147
}
140
148
141
- /// Sets the current active routine. At the moment this is just the latest,
142
- /// but this might change in the future.
143
- void setActiveRoutine () {
144
- if (_routines.isNotEmpty) {
145
- activeRoutine = _routines.first;
146
- } else {
147
- activeRoutine = null ;
148
- }
149
- }
150
-
151
149
/*
152
150
* Routines
153
151
*/
@@ -165,7 +163,6 @@ class RoutinesProvider with ChangeNotifier {
165
163
await fetchAndSetRoutineFull (entry['id' ]);
166
164
}
167
165
168
- setActiveRoutine ();
169
166
notifyListeners ();
170
167
}
171
168
@@ -181,7 +178,6 @@ class RoutinesProvider with ChangeNotifier {
181
178
_routines.add (plan);
182
179
}
183
180
184
- setActiveRoutine ();
185
181
notifyListeners ();
186
182
}
187
183
@@ -220,7 +216,6 @@ class RoutinesProvider with ChangeNotifier {
220
216
_routines.add (routine);
221
217
_routines.sort ((a, b) => b.created.compareTo (a.created));
222
218
223
- setActiveRoutine ();
224
219
notifyListeners ();
225
220
return routine;
226
221
}
@@ -338,7 +333,6 @@ class RoutinesProvider with ChangeNotifier {
338
333
_routines.add (routine);
339
334
}
340
335
341
- setActiveRoutine ();
342
336
notifyListeners ();
343
337
return routine;
344
338
}
0 commit comments