Skip to content

Commit 10f82e2

Browse files
authored
Merge pull request #918 from wger-project/fix/make-routineId-nullable
Make routineId nullable in session and related files
2 parents 3747e81 + 798406e commit 10f82e2

36 files changed

+205
-171
lines changed

lib/models/workouts/session.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class WorkoutSession {
3131
int? id;
3232

3333
@JsonKey(required: true, name: 'routine')
34-
late int routineId;
34+
late int? routineId;
3535

3636
@JsonKey(required: true, name: 'day')
3737
int? dayId;

lib/models/workouts/session.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/providers/routines.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,17 @@ class RoutinesProvider with ChangeNotifier {
628628
return sessions;
629629
}
630630

631-
Future<WorkoutSession> addSession(WorkoutSession session, int routineId) async {
631+
Future<WorkoutSession> addSession(WorkoutSession session, int? routineId) async {
632632
final data = await baseProvider.post(
633633
session.toJson(),
634634
baseProvider.makeUrl(_sessionUrlPath),
635635
);
636636
final newSession = WorkoutSession.fromJson(data);
637-
final routine = findById(routineId);
638-
routine.sessions.add(WorkoutSessionApi(session: newSession));
637+
638+
if (routineId != null) {
639+
final routine = findById(routineId);
640+
routine.sessions.add(WorkoutSessionApi(session: newSession));
641+
}
639642

640643
notifyListeners();
641644
return newSession;

lib/widgets/routines/forms/session.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import 'package:wger/providers/routines.dart';
3131
class SessionForm extends StatefulWidget {
3232
final _logger = Logger('SessionForm');
3333
final WorkoutSession _session;
34-
final int _routineId;
34+
final int? _routineId;
3535
final Function()? _onSaved;
3636

3737
static const SLIDER_START = -0.5;

lib/widgets/routines/log.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class _SessionInfoState extends State<SessionInfo> {
6565
),
6666
if (editMode)
6767
SessionForm(
68-
widget._session.routineId,
68+
widget._session.routineId!,
6969
onSaved: () => setState(() => editMode = false),
7070
session: widget._session,
7171
)

test/auth/auth_screen_test.mocks.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:mockito/src/dummies.dart' as _i5;
2424
// ignore_for_file: unnecessary_parenthesis
2525
// ignore_for_file: camel_case_types
2626
// ignore_for_file: subtype_of_sealed_class
27+
// ignore_for_file: invalid_use_of_internal_member
2728

2829
class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
2930
_FakeResponse_0(

test/core/settings_test.mocks.dart

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import 'package:wger/providers/user.dart' as _i22;
4242
// ignore_for_file: unnecessary_parenthesis
4343
// ignore_for_file: camel_case_types
4444
// ignore_for_file: subtype_of_sealed_class
45+
// ignore_for_file: invalid_use_of_internal_member
4546

4647
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
4748
_FakeWgerBaseProvider_0(
@@ -282,19 +283,19 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider {
282283
) as List<_i8.Language>);
283284

284285
@override
285-
set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod(
286+
set database(_i3.ExerciseDatabase? value) => super.noSuchMethod(
286287
Invocation.setter(
287288
#database,
288-
_database,
289+
value,
289290
),
290291
returnValueForMissingStub: null,
291292
);
292293

293294
@override
294-
set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod(
295+
set exercises(List<_i4.Exercise>? value) => super.noSuchMethod(
295296
Invocation.setter(
296297
#exercises,
297-
_exercises,
298+
value,
298299
),
299300
returnValueForMissingStub: null,
300301
);
@@ -724,19 +725,19 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans
724725
) as List<_i10.NutritionalPlan>);
725726

726727
@override
727-
set database(_i9.IngredientDatabase? _database) => super.noSuchMethod(
728+
set database(_i9.IngredientDatabase? value) => super.noSuchMethod(
728729
Invocation.setter(
729730
#database,
730-
_database,
731+
value,
731732
),
732733
returnValueForMissingStub: null,
733734
);
734735

735736
@override
736-
set ingredients(List<_i13.Ingredient>? _ingredients) => super.noSuchMethod(
737+
set ingredients(List<_i13.Ingredient>? value) => super.noSuchMethod(
737738
Invocation.setter(
738739
#ingredients,
739-
_ingredients,
740+
value,
740741
),
741742
returnValueForMissingStub: null,
742743
);
@@ -1149,28 +1150,28 @@ class MockUserProvider extends _i1.Mock implements _i22.UserProvider {
11491150
) as _i14.SharedPreferencesAsync);
11501151

11511152
@override
1152-
set themeMode(_i23.ThemeMode? _themeMode) => super.noSuchMethod(
1153+
set themeMode(_i23.ThemeMode? value) => super.noSuchMethod(
11531154
Invocation.setter(
11541155
#themeMode,
1155-
_themeMode,
1156+
value,
11561157
),
11571158
returnValueForMissingStub: null,
11581159
);
11591160

11601161
@override
1161-
set prefs(_i14.SharedPreferencesAsync? _prefs) => super.noSuchMethod(
1162+
set prefs(_i14.SharedPreferencesAsync? value) => super.noSuchMethod(
11621163
Invocation.setter(
11631164
#prefs,
1164-
_prefs,
1165+
value,
11651166
),
11661167
returnValueForMissingStub: null,
11671168
);
11681169

11691170
@override
1170-
set profile(_i24.Profile? _profile) => super.noSuchMethod(
1171+
set profile(_i24.Profile? value) => super.noSuchMethod(
11711172
Invocation.setter(
11721173
#profile,
1173-
_profile,
1174+
value,
11741175
),
11751176
returnValueForMissingStub: null,
11761177
);
@@ -1293,19 +1294,19 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
12931294
) as _i16.Client);
12941295

12951296
@override
1296-
set auth(_i15.AuthProvider? _auth) => super.noSuchMethod(
1297+
set auth(_i15.AuthProvider? value) => super.noSuchMethod(
12971298
Invocation.setter(
12981299
#auth,
1299-
_auth,
1300+
value,
13001301
),
13011302
returnValueForMissingStub: null,
13021303
);
13031304

13041305
@override
1305-
set client(_i16.Client? _client) => super.noSuchMethod(
1306+
set client(_i16.Client? value) => super.noSuchMethod(
13061307
Invocation.setter(
13071308
#client,
1308-
_client,
1309+
value,
13091310
),
13101311
returnValueForMissingStub: null,
13111312
);

test/exercises/contribute_exercise_test.mocks.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import 'package:wger/providers/user.dart' as _i17;
3838
// ignore_for_file: unnecessary_parenthesis
3939
// ignore_for_file: camel_case_types
4040
// ignore_for_file: subtype_of_sealed_class
41+
// ignore_for_file: invalid_use_of_internal_member
4142

4243
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
4344
_FakeWgerBaseProvider_0(
@@ -233,19 +234,19 @@ class MockAddExerciseProvider extends _i1.Mock implements _i13.AddExerciseProvid
233234
) as List<_i11.Muscle>);
234235

235236
@override
236-
set language(_i12.Language? _language) => super.noSuchMethod(
237+
set language(_i12.Language? value) => super.noSuchMethod(
237238
Invocation.setter(
238239
#language,
239-
_language,
240+
value,
240241
),
241242
returnValueForMissingStub: null,
242243
);
243244

244245
@override
245-
set category(_i9.ExerciseCategory? _category) => super.noSuchMethod(
246+
set category(_i9.ExerciseCategory? value) => super.noSuchMethod(
246247
Invocation.setter(
247248
#category,
248-
_category,
249+
value,
249250
),
250251
returnValueForMissingStub: null,
251252
);
@@ -551,28 +552,28 @@ class MockUserProvider extends _i1.Mock implements _i17.UserProvider {
551552
) as _i7.SharedPreferencesAsync);
552553

553554
@override
554-
set themeMode(_i18.ThemeMode? _themeMode) => super.noSuchMethod(
555+
set themeMode(_i18.ThemeMode? value) => super.noSuchMethod(
555556
Invocation.setter(
556557
#themeMode,
557-
_themeMode,
558+
value,
558559
),
559560
returnValueForMissingStub: null,
560561
);
561562

562563
@override
563-
set prefs(_i7.SharedPreferencesAsync? _prefs) => super.noSuchMethod(
564+
set prefs(_i7.SharedPreferencesAsync? value) => super.noSuchMethod(
564565
Invocation.setter(
565566
#prefs,
566-
_prefs,
567+
value,
567568
),
568569
returnValueForMissingStub: null,
569570
);
570571

571572
@override
572-
set profile(_i19.Profile? _profile) => super.noSuchMethod(
573+
set profile(_i19.Profile? value) => super.noSuchMethod(
573574
Invocation.setter(
574575
#profile,
575-
_profile,
576+
value,
576577
),
577578
returnValueForMissingStub: null,
578579
);
@@ -737,19 +738,19 @@ class MockExercisesProvider extends _i1.Mock implements _i20.ExercisesProvider {
737738
) as List<_i12.Language>);
738739

739740
@override
740-
set database(_i8.ExerciseDatabase? _database) => super.noSuchMethod(
741+
set database(_i8.ExerciseDatabase? value) => super.noSuchMethod(
741742
Invocation.setter(
742743
#database,
743-
_database,
744+
value,
744745
),
745746
returnValueForMissingStub: null,
746747
);
747748

748749
@override
749-
set exercises(List<_i3.Exercise>? _exercises) => super.noSuchMethod(
750+
set exercises(List<_i3.Exercise>? value) => super.noSuchMethod(
750751
Invocation.setter(
751752
#exercises,
752-
_exercises,
753+
value,
753754
),
754755
returnValueForMissingStub: null,
755756
);

test/exercises/exercises_detail_widget_test.mocks.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'package:wger/providers/exercises.dart' as _i9;
2929
// ignore_for_file: unnecessary_parenthesis
3030
// ignore_for_file: camel_case_types
3131
// ignore_for_file: subtype_of_sealed_class
32+
// ignore_for_file: invalid_use_of_internal_member
3233

3334
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
3435
_FakeWgerBaseProvider_0(
@@ -169,19 +170,19 @@ class MockExercisesProvider extends _i1.Mock implements _i9.ExercisesProvider {
169170
) as List<_i8.Language>);
170171

171172
@override
172-
set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod(
173+
set database(_i3.ExerciseDatabase? value) => super.noSuchMethod(
173174
Invocation.setter(
174175
#database,
175-
_database,
176+
value,
176177
),
177178
returnValueForMissingStub: null,
178179
);
179180

180181
@override
181-
set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod(
182+
set exercises(List<_i4.Exercise>? value) => super.noSuchMethod(
182183
Invocation.setter(
183184
#exercises,
184-
_exercises,
185+
value,
185186
),
186187
returnValueForMissingStub: null,
187188
);

test/gallery/gallery_form_test.mocks.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import 'package:wger/providers/gallery.dart' as _i4;
2626
// ignore_for_file: unnecessary_parenthesis
2727
// ignore_for_file: camel_case_types
2828
// ignore_for_file: subtype_of_sealed_class
29+
// ignore_for_file: invalid_use_of_internal_member
2930

3031
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
3132
_FakeAuthProvider_0(
@@ -82,10 +83,10 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
8283
) as List<_i5.Image>);
8384

8485
@override
85-
set images(List<_i5.Image>? _images) => super.noSuchMethod(
86+
set images(List<_i5.Image>? value) => super.noSuchMethod(
8687
Invocation.setter(
8788
#images,
88-
_images,
89+
value,
8990
),
9091
returnValueForMissingStub: null,
9192
);
@@ -109,19 +110,19 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
109110
) as _i3.Client);
110111

111112
@override
112-
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
113+
set auth(_i2.AuthProvider? value) => super.noSuchMethod(
113114
Invocation.setter(
114115
#auth,
115-
_auth,
116+
value,
116117
),
117118
returnValueForMissingStub: null,
118119
);
119120

120121
@override
121-
set client(_i3.Client? _client) => super.noSuchMethod(
122+
set client(_i3.Client? value) => super.noSuchMethod(
122123
Invocation.setter(
123124
#client,
124-
_client,
125+
value,
125126
),
126127
returnValueForMissingStub: null,
127128
);

0 commit comments

Comments
 (0)