Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/models/workouts/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WorkoutSession {
int? id;

@JsonKey(required: true, name: 'routine')
late int routineId;
late int? routineId;

@JsonKey(required: true, name: 'day')
int? dayId;
Expand Down
2 changes: 1 addition & 1 deletion lib/models/workouts/session.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions lib/providers/routines.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,14 +628,17 @@ class RoutinesProvider with ChangeNotifier {
return sessions;
}

Future<WorkoutSession> addSession(WorkoutSession session, int routineId) async {
Future<WorkoutSession> addSession(WorkoutSession session, int? routineId) async {
final data = await baseProvider.post(
session.toJson(),
baseProvider.makeUrl(_sessionUrlPath),
);
final newSession = WorkoutSession.fromJson(data);
final routine = findById(routineId);
routine.sessions.add(WorkoutSessionApi(session: newSession));

if (routineId != null) {
final routine = findById(routineId);
routine.sessions.add(WorkoutSessionApi(session: newSession));
}

notifyListeners();
return newSession;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/routines/forms/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import 'package:wger/providers/routines.dart';
class SessionForm extends StatefulWidget {
final _logger = Logger('SessionForm');
final WorkoutSession _session;
final int _routineId;
final int? _routineId;
final Function()? _onSaved;

static const SLIDER_START = -0.5;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/routines/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _SessionInfoState extends State<SessionInfo> {
),
if (editMode)
SessionForm(
widget._session.routineId,
widget._session.routineId!,
onSaved: () => setState(() => editMode = false),
session: widget._session,
)
Expand Down
1 change: 1 addition & 0 deletions test/auth/auth_screen_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:mockito/src/dummies.dart' as _i5;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
_FakeResponse_0(
Expand Down
37 changes: 19 additions & 18 deletions test/core/settings_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import 'package:wger/providers/user.dart' as _i22;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

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

@override
set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod(
set database(_i3.ExerciseDatabase? value) => super.noSuchMethod(
Invocation.setter(
#database,
_database,
value,
),
returnValueForMissingStub: null,
);

@override
set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod(
set exercises(List<_i4.Exercise>? value) => super.noSuchMethod(
Invocation.setter(
#exercises,
_exercises,
value,
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -724,19 +725,19 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans
) as List<_i10.NutritionalPlan>);

@override
set database(_i9.IngredientDatabase? _database) => super.noSuchMethod(
set database(_i9.IngredientDatabase? value) => super.noSuchMethod(
Invocation.setter(
#database,
_database,
value,
),
returnValueForMissingStub: null,
);

@override
set ingredients(List<_i13.Ingredient>? _ingredients) => super.noSuchMethod(
set ingredients(List<_i13.Ingredient>? value) => super.noSuchMethod(
Invocation.setter(
#ingredients,
_ingredients,
value,
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -1149,28 +1150,28 @@ class MockUserProvider extends _i1.Mock implements _i22.UserProvider {
) as _i14.SharedPreferencesAsync);

@override
set themeMode(_i23.ThemeMode? _themeMode) => super.noSuchMethod(
set themeMode(_i23.ThemeMode? value) => super.noSuchMethod(
Invocation.setter(
#themeMode,
_themeMode,
value,
),
returnValueForMissingStub: null,
);

@override
set prefs(_i14.SharedPreferencesAsync? _prefs) => super.noSuchMethod(
set prefs(_i14.SharedPreferencesAsync? value) => super.noSuchMethod(
Invocation.setter(
#prefs,
_prefs,
value,
),
returnValueForMissingStub: null,
);

@override
set profile(_i24.Profile? _profile) => super.noSuchMethod(
set profile(_i24.Profile? value) => super.noSuchMethod(
Invocation.setter(
#profile,
_profile,
value,
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -1293,19 +1294,19 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider {
) as _i16.Client);

@override
set auth(_i15.AuthProvider? _auth) => super.noSuchMethod(
set auth(_i15.AuthProvider? value) => super.noSuchMethod(
Invocation.setter(
#auth,
_auth,
value,
),
returnValueForMissingStub: null,
);

@override
set client(_i16.Client? _client) => super.noSuchMethod(
set client(_i16.Client? value) => super.noSuchMethod(
Invocation.setter(
#client,
_client,
value,
),
returnValueForMissingStub: null,
);
Expand Down
29 changes: 15 additions & 14 deletions test/exercises/contribute_exercise_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import 'package:wger/providers/user.dart' as _i17;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

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

@override
set language(_i12.Language? _language) => super.noSuchMethod(
set language(_i12.Language? value) => super.noSuchMethod(
Invocation.setter(
#language,
_language,
value,
),
returnValueForMissingStub: null,
);

@override
set category(_i9.ExerciseCategory? _category) => super.noSuchMethod(
set category(_i9.ExerciseCategory? value) => super.noSuchMethod(
Invocation.setter(
#category,
_category,
value,
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -551,28 +552,28 @@ class MockUserProvider extends _i1.Mock implements _i17.UserProvider {
) as _i7.SharedPreferencesAsync);

@override
set themeMode(_i18.ThemeMode? _themeMode) => super.noSuchMethod(
set themeMode(_i18.ThemeMode? value) => super.noSuchMethod(
Invocation.setter(
#themeMode,
_themeMode,
value,
),
returnValueForMissingStub: null,
);

@override
set prefs(_i7.SharedPreferencesAsync? _prefs) => super.noSuchMethod(
set prefs(_i7.SharedPreferencesAsync? value) => super.noSuchMethod(
Invocation.setter(
#prefs,
_prefs,
value,
),
returnValueForMissingStub: null,
);

@override
set profile(_i19.Profile? _profile) => super.noSuchMethod(
set profile(_i19.Profile? value) => super.noSuchMethod(
Invocation.setter(
#profile,
_profile,
value,
),
returnValueForMissingStub: null,
);
Expand Down Expand Up @@ -737,19 +738,19 @@ class MockExercisesProvider extends _i1.Mock implements _i20.ExercisesProvider {
) as List<_i12.Language>);

@override
set database(_i8.ExerciseDatabase? _database) => super.noSuchMethod(
set database(_i8.ExerciseDatabase? value) => super.noSuchMethod(
Invocation.setter(
#database,
_database,
value,
),
returnValueForMissingStub: null,
);

@override
set exercises(List<_i3.Exercise>? _exercises) => super.noSuchMethod(
set exercises(List<_i3.Exercise>? value) => super.noSuchMethod(
Invocation.setter(
#exercises,
_exercises,
value,
),
returnValueForMissingStub: null,
);
Expand Down
9 changes: 5 additions & 4 deletions test/exercises/exercises_detail_widget_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'package:wger/providers/exercises.dart' as _i9;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

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

@override
set database(_i3.ExerciseDatabase? _database) => super.noSuchMethod(
set database(_i3.ExerciseDatabase? value) => super.noSuchMethod(
Invocation.setter(
#database,
_database,
value,
),
returnValueForMissingStub: null,
);

@override
set exercises(List<_i4.Exercise>? _exercises) => super.noSuchMethod(
set exercises(List<_i4.Exercise>? value) => super.noSuchMethod(
Invocation.setter(
#exercises,
_exercises,
value,
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 7 additions & 6 deletions test/gallery/gallery_form_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:wger/providers/gallery.dart' as _i4;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

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

@override
set images(List<_i5.Image>? _images) => super.noSuchMethod(
set images(List<_i5.Image>? value) => super.noSuchMethod(
Invocation.setter(
#images,
_images,
value,
),
returnValueForMissingStub: null,
);
Expand All @@ -109,19 +110,19 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
) as _i3.Client);

@override
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
set auth(_i2.AuthProvider? value) => super.noSuchMethod(
Invocation.setter(
#auth,
_auth,
value,
),
returnValueForMissingStub: null,
);

@override
set client(_i3.Client? _client) => super.noSuchMethod(
set client(_i3.Client? value) => super.noSuchMethod(
Invocation.setter(
#client,
_client,
value,
),
returnValueForMissingStub: null,
);
Expand Down
13 changes: 7 additions & 6 deletions test/gallery/gallery_screen_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:wger/providers/gallery.dart' as _i4;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member

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

@override
set images(List<_i5.Image>? _images) => super.noSuchMethod(
set images(List<_i5.Image>? value) => super.noSuchMethod(
Invocation.setter(
#images,
_images,
value,
),
returnValueForMissingStub: null,
);
Expand All @@ -109,19 +110,19 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider {
) as _i3.Client);

@override
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
set auth(_i2.AuthProvider? value) => super.noSuchMethod(
Invocation.setter(
#auth,
_auth,
value,
),
returnValueForMissingStub: null,
);

@override
set client(_i3.Client? _client) => super.noSuchMethod(
set client(_i3.Client? value) => super.noSuchMethod(
Invocation.setter(
#client,
_client,
value,
),
returnValueForMissingStub: null,
);
Expand Down
Loading