From 39eaf9abe09bdc9f37363207df918d95beb9d8b3 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 7 May 2026 21:39:27 +0200 Subject: [PATCH] Make the linter happy --- .../measurements/measurement_category.dart | 5 +-- lib/models/workouts/base_config.g.dart | 2 +- lib/widgets/core/image.dart | 8 ++-- lib/widgets/exercises/images.dart | 2 +- lib/widgets/nutrition/nutrition_tile.dart | 4 +- lib/widgets/routines/gym_mode/summary.dart | 2 +- test/core/validators_test.mocks.dart | 44 +++++++++++++++++++ .../nutritional_plan_screen_test.mocks.dart | 22 ++++++++++ .../nutritional_plans_screen_test.mocks.dart | 22 ++++++++++ 9 files changed, 99 insertions(+), 12 deletions(-) diff --git a/lib/models/measurements/measurement_category.dart b/lib/models/measurements/measurement_category.dart index e5c8cdfd3..05d6ade02 100644 --- a/lib/models/measurements/measurement_category.dart +++ b/lib/models/measurements/measurement_category.dart @@ -40,7 +40,7 @@ class MeasurementCategory extends Equatable { ); } - MeasurementEntry findEntryById(entryId) { + MeasurementEntry findEntryById(int entryId) { return entries.firstWhere( (entry) => entry.id == entryId, orElse: () => throw const NoSuchEntryException(), @@ -57,6 +57,5 @@ class MeasurementCategory extends Equatable { List get props => [id, name, unit, entries]; // Helper function which makes the entries list of the toJson output null, as it isn't needed - //ignore: always_declare_return_types - static _nullValue(_) => null; + static Null _nullValue(List _) => null; } diff --git a/lib/models/workouts/base_config.g.dart b/lib/models/workouts/base_config.g.dart index a3513312a..8011f55d8 100644 --- a/lib/models/workouts/base_config.g.dart +++ b/lib/models/workouts/base_config.g.dart @@ -28,7 +28,7 @@ BaseConfig _$BaseConfigFromJson(Map json) { value: stringOrIntToNum(json['value']), operation: json['operation'] as String? ?? 'r', step: json['step'] as String? ?? 'abs', - requirements: json['requirements'] as Map? ?? null, + requirements: json['requirements'] as Map?, ); } diff --git a/lib/widgets/core/image.dart b/lib/widgets/core/image.dart index 42b175dca..7e315946d 100644 --- a/lib/widgets/core/image.dart +++ b/lib/widgets/core/image.dart @@ -16,12 +16,12 @@ Widget handleImageError( // NOTE: for the moment the other error messages are not localized String message = ''; - switch (error.runtimeType) { - case NetworkImageLoadException: + switch (error) { + case NetworkImageLoadException _: message = 'Network error'; - case HttpException: + case HttpException _: message = 'Http error'; - case FormatException: + case FormatException _: //TODO: not sure if this is the right exception for unsupported image formats? message = AppLocalizations.of(context).imageFormatNotSupported(imageFormat); default: diff --git a/lib/widgets/exercises/images.dart b/lib/widgets/exercises/images.dart index 9bac054d4..f3ea41b5f 100644 --- a/lib/widgets/exercises/images.dart +++ b/lib/widgets/exercises/images.dart @@ -21,7 +21,7 @@ import 'package:wger/models/exercises/image.dart'; import 'package:wger/widgets/core/image.dart'; class ExerciseImageWidget extends StatelessWidget { - ExerciseImageWidget({this.image, this.height}); + const ExerciseImageWidget({this.image, this.height}); final ExerciseImage? image; final double? height; diff --git a/lib/widgets/nutrition/nutrition_tile.dart b/lib/widgets/nutrition/nutrition_tile.dart index 4e1cc5b48..22de42b3c 100644 --- a/lib/widgets/nutrition/nutrition_tile.dart +++ b/lib/widgets/nutrition/nutrition_tile.dart @@ -32,8 +32,8 @@ class NutritionTile extends StatelessWidget { Expanded( child: Column( children: [ - if (title != null) title!, - if (subtitle != null) subtitle!, + ?title, + ?subtitle, ], ), ), diff --git a/lib/widgets/routines/gym_mode/summary.dart b/lib/widgets/routines/gym_mode/summary.dart index 9170b0995..19f883b10 100644 --- a/lib/widgets/routines/gym_mode/summary.dart +++ b/lib/widgets/routines/gym_mode/summary.dart @@ -127,7 +127,7 @@ class WorkoutSessionStats extends ConsumerWidget { final WorkoutSessionApi? _sessionApi; final List _userPrTrophies; - WorkoutSessionStats(this._sessionApi, this._userPrTrophies, {super.key}); + const WorkoutSessionStats(this._sessionApi, this._userPrTrophies, {super.key}); @override Widget build(BuildContext context, WidgetRef ref) { diff --git a/test/core/validators_test.mocks.dart b/test/core/validators_test.mocks.dart index f3ccae9a1..6b7f02fce 100644 --- a/test/core/validators_test.mocks.dart +++ b/test/core/validators_test.mocks.dart @@ -4041,6 +4041,50 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations { ) as String); + @override + String get serverConfigIssueTitle => + (super.noSuchMethod( + Invocation.getter(#serverConfigIssueTitle), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#serverConfigIssueTitle), + ), + ) + as String); + + @override + String get serverConfigIssueMessage => + (super.noSuchMethod( + Invocation.getter(#serverConfigIssueMessage), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#serverConfigIssueMessage), + ), + ) + as String); + + @override + String get understand => + (super.noSuchMethod( + Invocation.getter(#understand), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#understand), + ), + ) + as String); + + @override + String get viewDocumentation => + (super.noSuchMethod( + Invocation.getter(#viewDocumentation), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#viewDocumentation), + ), + ) + as String); + @override String exerciseNr(String? nr) => (super.noSuchMethod( diff --git a/test/nutrition/nutritional_plan_screen_test.mocks.dart b/test/nutrition/nutritional_plan_screen_test.mocks.dart index 774ecba72..985ae0859 100644 --- a/test/nutrition/nutritional_plan_screen_test.mocks.dart +++ b/test/nutrition/nutritional_plan_screen_test.mocks.dart @@ -225,6 +225,14 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { ) as _i2.AuthState); + @override + bool get serverConfigWarning => + (super.noSuchMethod( + Invocation.getter(#serverConfigWarning), + returnValue: false, + ) + as bool); + @override _i3.Client get client => (super.noSuchMethod( @@ -292,6 +300,12 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); + @override + void clearServerConfigWarning() => super.noSuchMethod( + Invocation.method(#clearServerConfigWarning, []), + returnValueForMissingStub: null, + ); + @override _i5.Future setServerVersion() => (super.noSuchMethod( @@ -335,6 +349,14 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { ) as bool); + @override + _i5.Future serverConfigSane() => + (super.noSuchMethod( + Invocation.method(#serverConfigSane, []), + returnValue: _i5.Future.value(false), + ) + as _i5.Future); + @override _i5.Future<_i2.LoginActions> register({ required String? username, diff --git a/test/nutrition/nutritional_plans_screen_test.mocks.dart b/test/nutrition/nutritional_plans_screen_test.mocks.dart index 79c80bd21..3c437bc9f 100644 --- a/test/nutrition/nutritional_plans_screen_test.mocks.dart +++ b/test/nutrition/nutritional_plans_screen_test.mocks.dart @@ -75,6 +75,14 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { ) as _i3.AuthState); + @override + bool get serverConfigWarning => + (super.noSuchMethod( + Invocation.getter(#serverConfigWarning), + returnValue: false, + ) + as bool); + @override _i2.Client get client => (super.noSuchMethod( @@ -142,6 +150,12 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); + @override + void clearServerConfigWarning() => super.noSuchMethod( + Invocation.method(#clearServerConfigWarning, []), + returnValueForMissingStub: null, + ); + @override _i5.Future setServerVersion() => (super.noSuchMethod( @@ -185,6 +199,14 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { ) as bool); + @override + _i5.Future serverConfigSane() => + (super.noSuchMethod( + Invocation.method(#serverConfigSane, []), + returnValue: _i5.Future.value(false), + ) + as _i5.Future); + @override _i5.Future<_i3.LoginActions> register({ required String? username,