diff --git a/lib/models/exercises/exercise.dart b/lib/models/exercises/exercise.dart
index 2929dce9..a6c322be 100644
--- a/lib/models/exercises/exercise.dart
+++ b/lib/models/exercises/exercise.dart
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+import 'package:collection/collection.dart';
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/consts.dart';
@@ -194,11 +195,7 @@ class Exercise extends Equatable {
}
ExerciseImage? get getMainImage {
- try {
- return images.firstWhere((image) => image.isMain);
- } on StateError {
- return null;
- }
+ return images.firstWhereOrNull((image) => image.isMain);
}
set setCategory(ExerciseCategory category) {
diff --git a/lib/models/exercises/exercise_api.freezed.dart b/lib/models/exercises/exercise_api.freezed.dart
index 1b0b52ea..1cd2141d 100644
--- a/lib/models/exercises/exercise_api.freezed.dart
+++ b/lib/models/exercises/exercise_api.freezed.dart
@@ -49,8 +49,12 @@ mixin _$ExerciseApiData {
@JsonKey(name: 'total_authors_history')
List get authorsGlobal => throw _privateConstructorUsedError;
+ /// Serializes this ExerciseApiData to a JSON map.
Map toJson() => throw _privateConstructorUsedError;
- @JsonKey(ignore: true)
+
+ /// Create a copy of ExerciseApiData
+ /// with the given fields replaced by the non-null parameter values.
+ @JsonKey(includeFromJson: false, includeToJson: false)
$ExerciseApiDataCopyWith get copyWith => throw _privateConstructorUsedError;
}
@@ -87,6 +91,8 @@ class _$ExerciseApiDataCopyWithImpl<$Res, $Val extends ExerciseApiData>
// ignore: unused_field
final $Res Function($Val) _then;
+ /// Create a copy of ExerciseApiData
+ /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
@@ -204,6 +210,8 @@ class __$$ExerciseBaseDataImplCopyWithImpl<$Res>
_$ExerciseBaseDataImpl _value, $Res Function(_$ExerciseBaseDataImpl) _then)
: super(_value, _then);
+ /// Create a copy of ExerciseApiData
+ /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
@@ -447,7 +455,7 @@ class _$ExerciseBaseDataImpl implements _ExerciseBaseData {
const DeepCollectionEquality().equals(other._authorsGlobal, _authorsGlobal));
}
- @JsonKey(ignore: true)
+ @JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
@@ -467,7 +475,9 @@ class _$ExerciseBaseDataImpl implements _ExerciseBaseData {
const DeepCollectionEquality().hash(_authors),
const DeepCollectionEquality().hash(_authorsGlobal));
- @JsonKey(ignore: true)
+ /// Create a copy of ExerciseApiData
+ /// with the given fields replaced by the non-null parameter values.
+ @JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ExerciseBaseDataImplCopyWith<_$ExerciseBaseDataImpl> get copyWith =>
@@ -505,43 +515,46 @@ abstract class _ExerciseBaseData implements ExerciseApiData {
@override
int get id;
@override
- String get uuid;
- @override // ignore: invalid_annotation_target
+ String get uuid; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'variations')
- int? get variationId;
- @override // ignore: invalid_annotation_target
+ int? get variationId; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'created')
- DateTime get created;
- @override // ignore: invalid_annotation_target
+ DateTime get created; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'last_update')
- DateTime get lastUpdate;
- @override // ignore: invalid_annotation_target
+ DateTime get lastUpdate; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'last_update_global')
DateTime get lastUpdateGlobal;
@override
ExerciseCategory get category;
@override
- List get muscles;
- @override // ignore: invalid_annotation_target
+ List get muscles; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'muscles_secondary')
- List get musclesSecondary;
- @override // ignore: invalid_annotation_target
- List get equipment;
- @override // ignore: invalid_annotation_target
+ List get musclesSecondary; // ignore: invalid_annotation_target
+ @override
+ List get equipment; // ignore: invalid_annotation_target
+ @override
@JsonKey(name: 'translations')
List get translations;
@override
List get images;
@override
- List