mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Properly handle null values
Basically all the fields can be nullable, so we need to set them if we want to avoid LateInitialisation errors.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2020 - 2025 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
|
||||
@@ -111,31 +111,23 @@ class Log {
|
||||
|
||||
Log.empty();
|
||||
|
||||
Log.fromSetConfigData(SetConfigData data) {
|
||||
Log.fromSetConfigData(SetConfigData setConfig) {
|
||||
date = DateTime.now();
|
||||
sessionId = null;
|
||||
|
||||
slotEntryId = data.slotEntryId;
|
||||
exerciseBase = data.exercise;
|
||||
slotEntryId = setConfig.slotEntryId;
|
||||
exerciseBase = setConfig.exercise;
|
||||
|
||||
if (data.weight != null) {
|
||||
weight = data.weight;
|
||||
weightTarget = data.weight;
|
||||
}
|
||||
if (data.weightUnit != null) {
|
||||
weightUnit = data.weightUnit;
|
||||
}
|
||||
weight = setConfig.weight;
|
||||
weightTarget = setConfig.weight;
|
||||
weightUnit = setConfig.weightUnit;
|
||||
|
||||
if (data.repetitions != null) {
|
||||
repetitions = data.repetitions;
|
||||
repetitionsTarget = data.repetitions;
|
||||
}
|
||||
if (data.repetitionsUnit != null) {
|
||||
repetitionUnit = data.repetitionsUnit;
|
||||
}
|
||||
repetitions = setConfig.repetitions;
|
||||
repetitionsTarget = setConfig.repetitions;
|
||||
repetitionUnit = setConfig.repetitionsUnit;
|
||||
|
||||
rir = data.rir;
|
||||
rirTarget = data.rir;
|
||||
rir = setConfig.rir;
|
||||
rirTarget = setConfig.rir;
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2025 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
|
||||
@@ -36,8 +36,8 @@ class SlotData {
|
||||
late List<SetConfigData> setConfigs;
|
||||
|
||||
SlotData({
|
||||
required this.comment,
|
||||
required this.isSuperset,
|
||||
this.comment = '',
|
||||
this.isSuperset = false,
|
||||
this.exerciseIds = const [],
|
||||
this.setConfigs = const [],
|
||||
});
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2025 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'slot_data.dart';
|
||||
@@ -12,8 +30,8 @@ SlotData _$SlotDataFromJson(Map<String, dynamic> json) {
|
||||
requiredKeys: const ['comment', 'is_superset', 'exercises', 'sets'],
|
||||
);
|
||||
return SlotData(
|
||||
comment: json['comment'] as String,
|
||||
isSuperset: json['is_superset'] as bool,
|
||||
comment: json['comment'] as String? ?? '',
|
||||
isSuperset: json['is_superset'] as bool? ?? false,
|
||||
exerciseIds:
|
||||
(json['exercises'] as List<dynamic>?)?.map((e) => (e as num).toInt()).toList() ?? const [],
|
||||
setConfigs:
|
||||
|
||||
Reference in New Issue
Block a user