diff --git a/lib/models/workouts/log.dart b/lib/models/workouts/log.dart index 495ff7d3..6559b565 100644 --- a/lib/models/workouts/log.dart +++ b/lib/models/workouts/log.dart @@ -101,16 +101,16 @@ class Log { this.repetitions, this.repetitionsTarget, this.repetitionsUnitId = REP_UNIT_REPETITIONS_ID, + this.repetitionsUnitObj, this.rir, this.rirTarget, this.weight, this.weightTarget, this.weightUnitId = WEIGHT_UNIT_KG, + this.weightUnitObj, DateTime? date, }) : date = date ?? DateTime.now(); - Log.empty(); - Log.fromSetConfigData(SetConfigData setConfig) { date = DateTime.now(); sessionId = null; @@ -142,9 +142,11 @@ class Log { num? repetitions, num? repetitionsTarget, int? repetitionsUnitId, + RepetitionUnit? repetitionsUnitObj, num? weight, num? weightTarget, int? weightUnitId, + WeightUnit? weightUnitObj, DateTime? date, }) { final out = Log( @@ -156,11 +158,13 @@ class Log { repetitions: repetitions ?? this.repetitions, repetitionsTarget: repetitionsTarget ?? this.repetitionsTarget, repetitionsUnitId: repetitionsUnitId ?? this.repetitionsUnitId, + repetitionsUnitObj: repetitionsUnitObj ?? this.repetitionsUnitObj, rir: rir ?? this.rir, rirTarget: rirTarget ?? this.rirTarget, weight: weight ?? this.weight, weightTarget: weightTarget ?? this.weightTarget, weightUnitId: weightUnitId ?? this.weightUnitId, + weightUnitObj: weightUnitObj ?? this.weightUnitObj, date: date ?? this.date, ); @@ -168,9 +172,16 @@ class Log { out.sessionId = sessionId; } + if (repetitionsUnitObj != null) { + out.repetitionsUnitObj = repetitionsUnitObj; + out.repetitionsUnitId = repetitionsUnitObj.id; + } + + if (weightUnitObj != null) { + out.weightUnitObj = weightUnitObj; + out.weightUnitId = weightUnitObj.id; + } out.exerciseBase = exercise; - out.repetitionUnit = repetitionsUnitObj; - out.weightUnitObj = weightUnitObj; return out; } diff --git a/lib/models/workouts/repetition_unit.dart b/lib/models/workouts/repetition_unit.dart index 55347d4e..0de31713 100644 --- a/lib/models/workouts/repetition_unit.dart +++ b/lib/models/workouts/repetition_unit.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -32,7 +32,7 @@ class RepetitionUnit { @override String toString() { - return 'RepetitionUnit{id: $id, name: $name}'; + return 'RepetitionUnit(id: $id, name: $name)'; } // Boilerplate diff --git a/lib/models/workouts/weight_unit.dart b/lib/models/workouts/weight_unit.dart index 2fab3e0a..460ecb01 100644 --- a/lib/models/workouts/weight_unit.dart +++ b/lib/models/workouts/weight_unit.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -30,6 +30,11 @@ class WeightUnit { const WeightUnit({required this.id, required this.name}); + @override + String toString() { + return 'WeightUnit(id: $id, name: $name)'; + } + // Boilerplate factory WeightUnit.fromJson(Map json) => _$WeightUnitFromJson(json); Map toJson() => _$WeightUnitToJson(this); diff --git a/lib/providers/gym_log_state.dart b/lib/providers/gym_log_state.dart index ec5e0452..5cb020e2 100644 --- a/lib/providers/gym_log_state.dart +++ b/lib/providers/gym_log_state.dart @@ -20,6 +20,8 @@ import 'package:clock/clock.dart'; import 'package:logging/logging.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:wger/models/workouts/log.dart'; +import 'package:wger/models/workouts/repetition_unit.dart'; +import 'package:wger/models/workouts/weight_unit.dart'; part 'gym_log_state.g.dart'; @@ -45,4 +47,12 @@ class GymLogNotifier extends _$GymLogNotifier { void setRepetitions(num repetitions) { state = state?.copyWith(repetitions: repetitions); } + + void setRepetitionUnit(RepetitionUnit repetitionUnit) { + state = state?.copyWith(repetitionsUnitObj: repetitionUnit); + } + + void setWeightUnit(WeightUnit weightUnit) { + state = state?.copyWith(weightUnitObj: weightUnit); + } } diff --git a/lib/widgets/routines/forms/reps_unit.dart b/lib/widgets/routines/forms/reps_unit.dart index f19d7e9f..14876575 100644 --- a/lib/widgets/routines/forms/reps_unit.dart +++ b/lib/widgets/routines/forms/reps_unit.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (c) 2020 - 2025 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -26,12 +26,10 @@ import 'package:wger/providers/routines.dart'; /// /// Can be used with a Setting or a Log object class RepetitionUnitInputWidget extends StatefulWidget { - late int? selectedRepetitionUnit; - final ValueChanged onChanged; + final RepetitionUnit? initialRepetitionUnit; + final ValueChanged onChanged; - RepetitionUnitInputWidget(int? initialValue, {super.key, required this.onChanged}) { - selectedRepetitionUnit = initialValue; - } + const RepetitionUnitInputWidget(this.initialRepetitionUnit, {super.key, required this.onChanged}); @override _RepetitionUnitInputWidgetState createState() => _RepetitionUnitInputWidgetState(); @@ -42,32 +40,31 @@ class _RepetitionUnitInputWidgetState extends State { Widget build(BuildContext context) { final unitProvider = context.read(); - RepetitionUnit? selectedWeightUnit = widget.selectedRepetitionUnit != null - ? unitProvider.findRepetitionUnitById(widget.selectedRepetitionUnit!) - : null; + RepetitionUnit? selectedWeightUnit = widget.initialRepetitionUnit; return DropdownButtonFormField( initialValue: selectedWeightUnit, - decoration: InputDecoration( - labelText: AppLocalizations.of(context).repetitionUnit, - ), + decoration: InputDecoration(labelText: AppLocalizations.of(context).repetitionUnit), isDense: true, onChanged: (RepetitionUnit? newValue) { + if (newValue == null) { + return; + } + setState(() { - selectedWeightUnit = newValue!; - widget.selectedRepetitionUnit = newValue.id; - widget.onChanged(newValue.id); + selectedWeightUnit = newValue; + widget.onChanged(newValue); }); }, - items: Provider.of(context, listen: false).repetitionUnits - .map>((RepetitionUnit value) { - return DropdownMenuItem( - key: Key(value.id.toString()), - value: value, - child: Text(value.name), - ); - }) - .toList(), + items: unitProvider.repetitionUnits.map>(( + RepetitionUnit value, + ) { + return DropdownMenuItem( + key: Key(value.id.toString()), + value: value, + child: Text(value.name), + ); + }).toList(), ); } } diff --git a/lib/widgets/routines/forms/slot_entry.dart b/lib/widgets/routines/forms/slot_entry.dart index a9580004..37213232 100644 --- a/lib/widgets/routines/forms/slot_entry.dart +++ b/lib/widgets/routines/forms/slot_entry.dart @@ -1,13 +1,13 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * wger Workout Manager is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. @@ -216,9 +216,14 @@ class _SlotEntryFormState extends State { ), if (!widget.simpleMode) WeightUnitInputWidget( - widget.entry.weightUnitId, + widget.entry.weightUnitObj, onChanged: (value) { - widget.entry.weightUnitId = value; + if (value != null) { + widget.entry.weightUnit = value; + } else { + widget.entry.weightUnitObj = null; + widget.entry.weightUnitId = null; + } }, ), Row( @@ -257,9 +262,14 @@ class _SlotEntryFormState extends State { ), if (!widget.simpleMode) RepetitionUnitInputWidget( - widget.entry.repetitionUnitId, + widget.entry.repetitionUnitObj, onChanged: (value) { - widget.entry.repetitionUnitId = value; + if (value != null) { + widget.entry.repetitionUnit = value; + } else { + widget.entry.repetitionUnitObj = null; + widget.entry.repetitionUnitId = null; + } }, ), Row( diff --git a/lib/widgets/routines/forms/weight_unit.dart b/lib/widgets/routines/forms/weight_unit.dart index 751c6e40..04b192ad 100644 --- a/lib/widgets/routines/forms/weight_unit.dart +++ b/lib/widgets/routines/forms/weight_unit.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (c) 2020 - 2025 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -26,12 +26,10 @@ import 'package:wger/providers/routines.dart'; /// /// Can be used with a Setting or a Log object class WeightUnitInputWidget extends StatefulWidget { - late int? selectedWeightUnit; - final ValueChanged onChanged; + final WeightUnit? selectedWeightUnit; + final ValueChanged onChanged; - WeightUnitInputWidget(int? initialValue, {super.key, required this.onChanged}) { - selectedWeightUnit = initialValue; - } + const WeightUnitInputWidget(this.selectedWeightUnit, {super.key, required this.onChanged}); @override _WeightUnitInputWidgetState createState() => _WeightUnitInputWidgetState(); @@ -42,29 +40,28 @@ class _WeightUnitInputWidgetState extends State { Widget build(BuildContext context) { final unitProvider = context.read(); - WeightUnit? selectedWeightUnit = widget.selectedWeightUnit != null - ? unitProvider.findWeightUnitById(widget.selectedWeightUnit!) - : null; + WeightUnit? selectedWeightUnit = widget.selectedWeightUnit; return DropdownButtonFormField( initialValue: selectedWeightUnit, decoration: InputDecoration(labelText: AppLocalizations.of(context).weightUnit), onChanged: (WeightUnit? newValue) { + if (newValue == null) { + return; + } + setState(() { - selectedWeightUnit = newValue!; - widget.selectedWeightUnit = newValue.id; - widget.onChanged(newValue.id); + selectedWeightUnit = newValue; + widget.onChanged(newValue); }); }, - items: Provider.of(context, listen: false).weightUnits - .map>((WeightUnit value) { - return DropdownMenuItem( - key: Key(value.id.toString()), - value: value, - child: Text(value.name), - ); - }) - .toList(), + items: unitProvider.weightUnits.map>((WeightUnit value) { + return DropdownMenuItem( + key: Key(value.id.toString()), + value: value, + child: Text(value.name), + ); + }).toList(), ); } } diff --git a/lib/widgets/routines/gym_mode/log_page.dart b/lib/widgets/routines/gym_mode/log_page.dart index fd40effe..597fd058 100644 --- a/lib/widgets/routines/gym_mode/log_page.dart +++ b/lib/widgets/routines/gym_mode/log_page.dart @@ -45,7 +45,6 @@ class LogPage extends ConsumerWidget { final PageController _controller; LogPage(this._controller); - final GlobalKey<_LogFormWidgetState> _logFormKey = GlobalKey<_LogFormWidgetState>(); @override Widget build(BuildContext context, WidgetRef ref) { @@ -70,7 +69,7 @@ class LogPage extends ConsumerWidget { } final setConfigData = slotEntryPage.setConfigData!; - final log = ref.watch(gymLogProvider); + final log = ref.read(gymLogProvider); // Mark done sets final decorationStyle = slotEntryPage.logDone @@ -145,8 +144,7 @@ class LogPage extends ConsumerWidget { child: LogFormWidget( controller: _controller, configData: setConfigData, - // log: log!, - key: _logFormKey, + key: ValueKey('log-form-${slotEntryPage.uuid}'), ), ), ), @@ -213,9 +211,11 @@ class LogsPlatesWidget extends ConsumerWidget { class LogsRepsWidget extends ConsumerStatefulWidget { final num valueChange; + final TextEditingController? controller; const LogsRepsWidget({ super.key, + this.controller, num? valueChange, }) : valueChange = valueChange ?? 1; @@ -226,16 +226,19 @@ class LogsRepsWidget extends ConsumerStatefulWidget { class _LogsRepsWidgetState extends ConsumerState { final _logger = Logger('LogsRepsWidget'); late TextEditingController _controller; + num? _lastReps; @override void initState() { super.initState(); - _controller = TextEditingController(); + _controller = widget.controller ?? TextEditingController(); } @override void dispose() { - _controller.dispose(); + if (widget.controller == null) { + _controller.dispose(); + } super.dispose(); } @@ -247,23 +250,19 @@ class _LogsRepsWidgetState extends ConsumerState { final logNotifier = ref.read(gymLogProvider.notifier); final log = ref.watch(gymLogProvider); final currentReps = log?.repetitions; - final currentInput = numberFormat.tryParse(_controller.text); - // Sync from provider to controller if needed - if (currentReps != null) { - // Update if values differ, but allow invalid input while typing (unless empty/initial) - if (currentInput != currentReps && (currentInput != null || _controller.text.isEmpty)) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { - _controller.text = numberFormat.format(currentReps); - } - }); - } - } else if (_controller.text.isNotEmpty) { + // Only update the controller when the provider value actually changed + if (currentReps != _lastReps) { WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { + if (!mounted) { + return; + } + if (currentReps != null) { + _controller.text = numberFormat.format(currentReps); + } else { _controller.clear(); } + _lastReps = currentReps; }); } @@ -329,9 +328,11 @@ class _LogsRepsWidgetState extends ConsumerState { class LogsWeightWidget extends ConsumerStatefulWidget { final num valueChange; + final TextEditingController? controller; const LogsWeightWidget({ super.key, + this.controller, num? valueChange, }) : valueChange = valueChange ?? 1.25; @@ -342,16 +343,19 @@ class LogsWeightWidget extends ConsumerStatefulWidget { class _LogsWeightWidgetState extends ConsumerState { final _logger = Logger('LogsWeightWidget'); late TextEditingController _controller; + num? _lastWeight; @override void initState() { super.initState(); - _controller = TextEditingController(); + _controller = widget.controller ?? TextEditingController(); } @override void dispose() { - _controller.dispose(); + if (widget.controller == null) { + _controller.dispose(); + } super.dispose(); } @@ -364,23 +368,19 @@ class _LogsWeightWidgetState extends ConsumerState { final logProvider = ref.read(gymLogProvider.notifier); final log = ref.watch(gymLogProvider); final currentWeight = log?.weight; - final currentInput = numberFormat.tryParse(_controller.text); - // Sync from provider to controller if needed - if (currentWeight != null) { - // Update if values differ, but allow invalid input while typing (unless empty/initial) - if (currentInput != currentWeight && (currentInput != null || _controller.text.isEmpty)) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { - _controller.text = numberFormat.format(currentWeight); - } - }); - } - } else if (_controller.text.isNotEmpty) { + // Only update when provider value changed + if (currentWeight != _lastWeight) { WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { + if (!mounted) { + return; + } + if (currentWeight != null) { + _controller.text = numberFormat.format(currentWeight); + } else { _controller.clear(); } + _lastWeight = currentWeight; }); } @@ -489,12 +489,10 @@ class LogsPastLogsWidget extends ConsumerWidget { } class LogFormWidget extends ConsumerStatefulWidget { - final _logger = Logger('LogFormWidget'); - final PageController controller; final SetConfigData configData; - LogFormWidget({ + const LogFormWidget({ super.key, required this.controller, required this.configData, @@ -556,8 +554,8 @@ class _LogFormWidgetState extends ConsumerState { Flexible( child: RepetitionUnitInputWidget( key: const ValueKey('repetition-unit-input-widget'), - log!.repetitionsUnitId, - onChanged: (v) => {}, + log!.repetitionsUnitObj, + onChanged: (v) => ref.read(gymLogProvider.notifier).setRepetitionUnit(v), ), ), const SizedBox(width: 8), @@ -576,8 +574,8 @@ class _LogFormWidgetState extends ConsumerState { const SizedBox(width: 8), Flexible( child: WeightUnitInputWidget( - log!.weightUnitId, - onChanged: (v) => {}, + log!.weightUnitObj, + onChanged: (v) => ref.read(gymLogProvider.notifier).setWeightUnit(v), key: const ValueKey('weight-unit-input-widget'), ), ), @@ -619,10 +617,11 @@ class _LogFormWidgetState extends ConsumerState { final gymState = ref.read(gymStateProvider); final gymProvider = ref.read(gymStateProvider.notifier); + final logToSave = ref.read(gymLogProvider); await provider.Provider.of( context, listen: false, - ).addLog(log!); + ).addLog(logToSave!); final page = gymState.getSlotEntryPageByIndex()!; gymProvider.markSlotPageAsDone(page.uuid, isDone: true); diff --git a/test/routine/repetition_unit_form_widget_test.dart b/test/routine/repetition_unit_form_widget_test.dart index 16d16949..43cb66f3 100644 --- a/test/routine/repetition_unit_form_widget_test.dart +++ b/test/routine/repetition_unit_form_widget_test.dart @@ -1,13 +1,13 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * wger Workout Manager is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. @@ -37,7 +37,7 @@ void main() { const unit2 = RepetitionUnit(id: 2, name: 'another name'); const unit3 = RepetitionUnit(id: 3, name: 'this is repetition number 3'); - int? result; + RepetitionUnit? result; final slotEntry = SlotEntry( slotId: 1, @@ -54,8 +54,6 @@ void main() { mockWorkoutPlans = MockRoutinesProvider(); result = null; when(mockWorkoutPlans.repetitionUnits).thenAnswer((_) => [unit1, unit2, unit3]); - when(mockWorkoutPlans.findRepetitionUnitById(1)).thenReturn(unit1); - when(mockWorkoutPlans.findRepetitionUnitById(2)).thenReturn(unit2); }); Widget renderWidget() { @@ -67,7 +65,12 @@ void main() { localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, navigatorKey: key, - home: Scaffold(body: RepetitionUnitInputWidget(1, onChanged: (value) => result = value)), + home: Scaffold( + body: RepetitionUnitInputWidget( + unit1, + onChanged: (value) => result = value, + ), + ), routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()}, ), ); @@ -96,6 +99,6 @@ void main() { await tester.tap(find.text('another name').last); // assert - expect(result, equals(2)); + expect(result, equals(unit2)); }); } diff --git a/test/routine/weight_unit_form_widget_test.dart b/test/routine/weight_unit_form_widget_test.dart index 231e32ea..1c489c55 100644 --- a/test/routine/weight_unit_form_widget_test.dart +++ b/test/routine/weight_unit_form_widget_test.dart @@ -1,13 +1,13 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020 - 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * wger Workout Manager is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. @@ -33,7 +33,7 @@ import 'weight_unit_form_widget_test.mocks.dart'; @GenerateMocks([RoutinesProvider]) void main() { var mockWorkoutPlans = MockRoutinesProvider(); - int? result; + WeightUnit? result; const unit1 = WeightUnit(id: 1, name: 'kg'); const unit2 = WeightUnit(id: 2, name: 'donkeys'); @@ -54,8 +54,6 @@ void main() { result = null; mockWorkoutPlans = MockRoutinesProvider(); when(mockWorkoutPlans.weightUnits).thenAnswer((_) => [unit1, unit2, unit3]); - when(mockWorkoutPlans.findWeightUnitById(1)).thenReturn(unit1); - when(mockWorkoutPlans.findWeightUnitById(2)).thenReturn(unit2); }); Widget renderWidget() { @@ -67,7 +65,7 @@ void main() { localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, navigatorKey: key, - home: Scaffold(body: WeightUnitInputWidget(1, onChanged: (value) => result = value)), + home: Scaffold(body: WeightUnitInputWidget(unit1, onChanged: (value) => result = value)), routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()}, ), ); @@ -97,6 +95,6 @@ void main() { await tester.tap(find.text('donkeys').last); // assert - expect(result, equals(2)); + expect(result, equals(unit2)); }); } diff --git a/test_data/routines.dart b/test_data/routines.dart index 73e330a4..46408631 100644 --- a/test_data/routines.dart +++ b/test_data/routines.dart @@ -1,13 +1,13 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * wger Workout Manager is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. @@ -45,41 +45,47 @@ const testRepetitionUnits = [testRepetitionUnit1, testRepetitionUnit2]; Routine getTestRoutine({List? exercises}) { final testExercises = exercises ?? getTestExercises(); - final log1 = Log.empty() - ..id = 1 - ..iteration = 2 - ..slotEntryId = 3 - ..weight = 10 - ..rir = 1.5 - ..date = DateTime(2021, 5, 1) - ..repetitions = 10 - ..routineId = 1; + final log1 = Log( + id: 1, + iteration: 2, + slotEntryId: 3, + weight: 10, + rir: 1.5, + date: DateTime(2021, 5, 1), + repetitions: 10, + routineId: 1, + exerciseId: testExercises[0].id!, + ); log1.exerciseBase = testExercises[0]; log1.weightUnit = testWeightUnit1; log1.repetitionUnit = testRepetitionUnit1; - final log2 = Log.empty() - ..id = 2 - ..iteration = 4 - ..slotEntryId = 1 - ..weight = 10 - ..rir = 2 - ..date = DateTime(2021, 5, 1) - ..repetitions = 12 - ..routineId = 1; + final log2 = Log( + id: 2, + iteration: 4, + slotEntryId: 1, + weight: 10, + rir: 2, + date: DateTime(2021, 5, 1), + repetitions: 12, + routineId: 1, + exerciseId: testExercises[0].id!, + ); log2.exerciseBase = testExercises[0]; log2.weightUnit = testWeightUnit1; log2.repetitionUnit = testRepetitionUnit1; - final log3 = Log.empty() - ..id = 3 - ..iteration = 5 - ..slotEntryId = 1 - ..weight = 50 - ..rir = null - ..date = DateTime(2021, 5, 2) - ..repetitions = 8 - ..routineId = 1; + final log3 = Log( + id: 3, + iteration: 5, + slotEntryId: 1, + weight: 50, + rir: null, + date: DateTime(2021, 5, 2), + repetitions: 8, + routineId: 1, + exerciseId: testExercises[1].id!, + ); log3.exerciseBase = testExercises[1]; log3.weightUnit = testWeightUnit1; log3.repetitionUnit = testRepetitionUnit1;