diff --git a/lib/helpers/json.dart b/lib/helpers/json.dart index d929afc0..a3f0a176 100644 --- a/lib/helpers/json.dart +++ b/lib/helpers/json.dart @@ -60,6 +60,5 @@ String? timeToString(TimeOfDay? time) { if (time == null) { return null; } - return DefaultMaterialLocalizations() - .formatTimeOfDay(time, alwaysUse24HourFormat: true); + return DefaultMaterialLocalizations().formatTimeOfDay(time, alwaysUse24HourFormat: true); } diff --git a/lib/helpers/misc.dart b/lib/helpers/misc.dart index d22ab76e..6da4ab20 100644 --- a/lib/helpers/misc.dart +++ b/lib/helpers/misc.dart @@ -41,9 +41,7 @@ String repText( // rather "8 repetitions". If there is weight we want to output "8 x 50kg", // since the repetitions are implied. If other units are used, we always // print them - if (repetitionUnitObj.id != DEFAULT_REPETITION_UNIT || - weight == 0 || - weight == null) { + if (repetitionUnitObj.id != DEFAULT_REPETITION_UNIT || weight == 0 || weight == null) { out.add(repetitionUnitObj.name); } } diff --git a/lib/helpers/ui.dart b/lib/helpers/ui.dart index 09d57803..b115e6ea 100644 --- a/lib/helpers/ui.dart +++ b/lib/helpers/ui.dart @@ -44,8 +44,7 @@ void showErrorDialog(dynamic exception, BuildContext context) { ); } -void showHttpExceptionErrorDialog( - WgerHttpException exception, BuildContext context) { +void showHttpExceptionErrorDialog(WgerHttpException exception, BuildContext context) { log('showHttpExceptionErrorDialog: '); log(exception.toString()); log('-------------------'); diff --git a/lib/main.dart b/lib/main.dart index 70086e88..0a076ed3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,37 +58,35 @@ class MyApp extends StatelessWidget { create: (ctx) => AuthProvider(), ), ChangeNotifierProxyProvider( - create: (context) => ExercisesProvider( - Provider.of(context, listen: false), []), + create: (context) => + ExercisesProvider(Provider.of(context, listen: false), []), update: (context, auth, previous) => previous != null ? previous : ExercisesProvider(auth, []), ), - ChangeNotifierProxyProvider2( + ChangeNotifierProxyProvider2( create: (context) => WorkoutPlansProvider( Provider.of(context, listen: false), Provider.of(context, listen: false), [], ), - update: (context, auth, exercises, previous) => previous != null - ? previous - : WorkoutPlansProvider(auth, exercises, []), + update: (context, auth, exercises, previous) => + previous != null ? previous : WorkoutPlansProvider(auth, exercises, []), ), ChangeNotifierProxyProvider( - create: (context) => NutritionPlansProvider( - Provider.of(context, listen: false), []), + create: (context) => + NutritionPlansProvider(Provider.of(context, listen: false), []), update: (context, auth, previous) => previous != null ? previous : NutritionPlansProvider(auth, []), ), ChangeNotifierProxyProvider( - create: (context) => BodyWeightProvider( - Provider.of(context, listen: false), []), + create: (context) => + BodyWeightProvider(Provider.of(context, listen: false), []), update: (context, auth, previous) => previous != null ? previous : BodyWeightProvider(auth, []), ), ChangeNotifierProxyProvider( - create: (context) => GalleryProvider( - Provider.of(context, listen: false), []), + create: (context) => + GalleryProvider(Provider.of(context, listen: false), []), update: (context, auth, previous) => previous != null ? previous : GalleryProvider(auth, []), ), @@ -102,8 +100,7 @@ class MyApp extends StatelessWidget { : FutureBuilder( future: auth.tryAutoLogin(), builder: (ctx, authResultSnapshot) => - authResultSnapshot.connectionState == - ConnectionState.waiting + authResultSnapshot.connectionState == ConnectionState.waiting ? SplashScreen() : AuthScreen(), ), diff --git a/lib/models/body_weight/weight_entry.dart b/lib/models/body_weight/weight_entry.dart index 4ab714e7..1fbb5dbf 100644 --- a/lib/models/body_weight/weight_entry.dart +++ b/lib/models/body_weight/weight_entry.dart @@ -45,7 +45,6 @@ class WeightEntry { } // Boilerplate - factory WeightEntry.fromJson(Map json) => - _$WeightEntryFromJson(json); + factory WeightEntry.fromJson(Map json) => _$WeightEntryFromJson(json); Map toJson() => _$WeightEntryToJson(this); } diff --git a/lib/models/body_weight/weight_entry.g.dart b/lib/models/body_weight/weight_entry.g.dart index e4ac9e9b..98ab3eda 100644 --- a/lib/models/body_weight/weight_entry.g.dart +++ b/lib/models/body_weight/weight_entry.g.dart @@ -15,8 +15,7 @@ WeightEntry _$WeightEntryFromJson(Map json) { ); } -Map _$WeightEntryToJson(WeightEntry instance) => - { +Map _$WeightEntryToJson(WeightEntry instance) => { 'id': instance.id, 'weight': numToString(instance.weight), 'date': toDate(instance.date), diff --git a/lib/models/exercises/category.dart b/lib/models/exercises/category.dart index f5f52707..9b15dc1b 100644 --- a/lib/models/exercises/category.dart +++ b/lib/models/exercises/category.dart @@ -39,7 +39,6 @@ class ExerciseCategory { } // Boilerplate - factory ExerciseCategory.fromJson(Map json) => - _$ExerciseCategoryFromJson(json); + factory ExerciseCategory.fromJson(Map json) => _$ExerciseCategoryFromJson(json); Map toJson() => _$ExerciseCategoryToJson(this); } diff --git a/lib/models/exercises/category.g.dart b/lib/models/exercises/category.g.dart index 109bac45..5083051f 100644 --- a/lib/models/exercises/category.g.dart +++ b/lib/models/exercises/category.g.dart @@ -14,8 +14,7 @@ ExerciseCategory _$ExerciseCategoryFromJson(Map json) { ); } -Map _$ExerciseCategoryToJson(ExerciseCategory instance) => - { +Map _$ExerciseCategoryToJson(ExerciseCategory instance) => { 'id': instance.id, 'name': instance.name, }; diff --git a/lib/models/exercises/comment.dart b/lib/models/exercises/comment.dart index 13f87564..e9461502 100644 --- a/lib/models/exercises/comment.dart +++ b/lib/models/exercises/comment.dart @@ -34,7 +34,6 @@ class Comment { }); // Boilerplate - factory Comment.fromJson(Map json) => - _$CommentFromJson(json); + factory Comment.fromJson(Map json) => _$CommentFromJson(json); Map toJson() => _$CommentToJson(this); } diff --git a/lib/models/exercises/equipment.dart b/lib/models/exercises/equipment.dart index 4162a7cf..ea7713b8 100644 --- a/lib/models/exercises/equipment.dart +++ b/lib/models/exercises/equipment.dart @@ -34,7 +34,6 @@ class Equipment { }); // Boilerplate - factory Equipment.fromJson(Map json) => - _$EquipmentFromJson(json); + factory Equipment.fromJson(Map json) => _$EquipmentFromJson(json); Map toJson() => _$EquipmentToJson(this); } diff --git a/lib/models/exercises/exercise.dart b/lib/models/exercises/exercise.dart index 665c2cb0..2ee6f398 100644 --- a/lib/models/exercises/exercise.dart +++ b/lib/models/exercises/exercise.dart @@ -100,7 +100,6 @@ class Exercise { } // Boilerplate - factory Exercise.fromJson(Map json) => - _$ExerciseFromJson(json); + factory Exercise.fromJson(Map json) => _$ExerciseFromJson(json); Map toJson() => _$ExerciseToJson(this); } diff --git a/lib/models/exercises/exercise.g.dart b/lib/models/exercises/exercise.g.dart index 2ac8fe7a..75051579 100644 --- a/lib/models/exercises/exercise.g.dart +++ b/lib/models/exercises/exercise.g.dart @@ -42,8 +42,7 @@ Exercise _$ExerciseFromJson(Map json) { tips: (json['comments'] as List?) ?.map((e) => Comment.fromJson(e as Map)) .toList(), - )..categoryObj = - ExerciseCategory.fromJson(json['category'] as Map); + )..categoryObj = ExerciseCategory.fromJson(json['category'] as Map); } Map _$ExerciseToJson(Exercise instance) => { @@ -55,8 +54,7 @@ Map _$ExerciseToJson(Exercise instance) => { 'categoryId': instance.categoryId, 'category': instance.categoryObj.toJson(), 'muscles': instance.muscles.map((e) => e.toJson()).toList(), - 'muscles_secondary': - instance.musclesSecondary.map((e) => e.toJson()).toList(), + 'muscles_secondary': instance.musclesSecondary.map((e) => e.toJson()).toList(), 'equipment': instance.equipment.map((e) => e.toJson()).toList(), 'images': instance.images.map((e) => e.toJson()).toList(), 'comments': instance.tips.map((e) => e.toJson()).toList(), diff --git a/lib/models/exercises/image.dart b/lib/models/exercises/image.dart index 7cd2e582..78890bb1 100644 --- a/lib/models/exercises/image.dart +++ b/lib/models/exercises/image.dart @@ -46,7 +46,6 @@ class ExerciseImage { }); // Boilerplate - factory ExerciseImage.fromJson(Map json) => - _$ExerciseImageFromJson(json); + factory ExerciseImage.fromJson(Map json) => _$ExerciseImageFromJson(json); Map toJson() => _$ExerciseImageToJson(this); } diff --git a/lib/models/exercises/image.g.dart b/lib/models/exercises/image.g.dart index d3fc1a55..c55b4029 100644 --- a/lib/models/exercises/image.g.dart +++ b/lib/models/exercises/image.g.dart @@ -7,8 +7,7 @@ part of 'image.dart'; // ************************************************************************** ExerciseImage _$ExerciseImageFromJson(Map json) { - $checkKeys(json, - requiredKeys: const ['id', 'uuid', 'exercise_base', 'image']); + $checkKeys(json, requiredKeys: const ['id', 'uuid', 'exercise_base', 'image']); return ExerciseImage( id: json['id'] as int, uuid: json['uuid'] as String, @@ -18,8 +17,7 @@ ExerciseImage _$ExerciseImageFromJson(Map json) { ); } -Map _$ExerciseImageToJson(ExerciseImage instance) => - { +Map _$ExerciseImageToJson(ExerciseImage instance) => { 'id': instance.id, 'uuid': instance.uuid, 'exercise_base': instance.exerciseBaseId, diff --git a/lib/models/http_exception.dart b/lib/models/http_exception.dart index 6b2598be..d2d48ddc 100644 --- a/lib/models/http_exception.dart +++ b/lib/models/http_exception.dart @@ -26,10 +26,7 @@ class WgerHttpException implements Exception { /// JSON. Will use the response as-is if it fails. WgerHttpException(dynamic responseBody) { if (responseBody == null) { - errors = { - 'unknown_error': - 'An unknown error occurred, no further information available' - }; + errors = {'unknown_error': 'An unknown error occurred, no further information available'}; } else { try { errors = json.decode(responseBody); diff --git a/lib/models/nutrition/ingredient.dart b/lib/models/nutrition/ingredient.dart index 122ec1c5..69d1ce44 100644 --- a/lib/models/nutrition/ingredient.dart +++ b/lib/models/nutrition/ingredient.dart @@ -41,11 +41,7 @@ class Ingredient { final num carbohydrates; /// g per 100g of product - @JsonKey( - required: true, - fromJson: stringToNum, - toJson: numToString, - name: 'carbohydrates_sugar') + @JsonKey(required: true, fromJson: stringToNum, toJson: numToString, name: 'carbohydrates_sugar') final num carbohydratesSugar; /// g per 100g of product @@ -57,11 +53,7 @@ class Ingredient { final num fat; /// g per 100g of product - @JsonKey( - required: true, - fromJson: stringToNum, - toJson: numToString, - name: 'fat_saturated') + @JsonKey(required: true, fromJson: stringToNum, toJson: numToString, name: 'fat_saturated') final num fatSaturated; /// g per 100g of product @@ -87,7 +79,6 @@ class Ingredient { }); // Boilerplate - factory Ingredient.fromJson(Map json) => - _$IngredientFromJson(json); + factory Ingredient.fromJson(Map json) => _$IngredientFromJson(json); Map toJson() => _$IngredientToJson(this); } diff --git a/lib/models/nutrition/ingredient.g.dart b/lib/models/nutrition/ingredient.g.dart index 011a62bf..6ffb0a9c 100644 --- a/lib/models/nutrition/ingredient.g.dart +++ b/lib/models/nutrition/ingredient.g.dart @@ -35,8 +35,7 @@ Ingredient _$IngredientFromJson(Map json) { ); } -Map _$IngredientToJson(Ingredient instance) => - { +Map _$IngredientToJson(Ingredient instance) => { 'id': instance.id, 'name': instance.name, 'creation_date': toDate(instance.creationDate), diff --git a/lib/models/nutrition/ingredient_weight_unit.g.dart b/lib/models/nutrition/ingredient_weight_unit.g.dart index 8dc1e54d..600d0ed4 100644 --- a/lib/models/nutrition/ingredient_weight_unit.g.dart +++ b/lib/models/nutrition/ingredient_weight_unit.g.dart @@ -7,25 +7,17 @@ part of 'ingredient_weight_unit.dart'; // ************************************************************************** IngredientWeightUnit _$IngredientWeightUnitFromJson(Map json) { - $checkKeys(json, requiredKeys: const [ - 'id', - 'weight_unit', - 'ingredient', - 'grams', - 'amount' - ]); + $checkKeys(json, requiredKeys: const ['id', 'weight_unit', 'ingredient', 'grams', 'amount']); return IngredientWeightUnit( id: json['id'] as int, - weightUnit: - WeightUnit.fromJson(json['weight_unit'] as Map), + weightUnit: WeightUnit.fromJson(json['weight_unit'] as Map), ingredient: Ingredient.fromJson(json['ingredient'] as Map), grams: json['grams'] as int, amount: (json['amount'] as num).toDouble(), ); } -Map _$IngredientWeightUnitToJson( - IngredientWeightUnit instance) => +Map _$IngredientWeightUnitToJson(IngredientWeightUnit instance) => { 'id': instance.id, 'weight_unit': instance.weightUnit, diff --git a/lib/models/nutrition/log.dart b/lib/models/nutrition/log.dart index b424635a..3cdec7cb 100644 --- a/lib/models/nutrition/log.dart +++ b/lib/models/nutrition/log.dart @@ -82,9 +82,8 @@ class Log { var out = NutritionalValues(); //final weight = amount; - final weight = this.weightUnitObj == null - ? amount - : amount * weightUnitObj!.amount * weightUnitObj!.grams; + final weight = + this.weightUnitObj == null ? amount : amount * weightUnitObj!.amount * weightUnitObj!.grams; out.energy = ingredientObj.energy * weight / 100; out.protein = ingredientObj.protein * weight / 100; diff --git a/lib/models/nutrition/log.g.dart b/lib/models/nutrition/log.g.dart index 3bda3119..7e64e384 100644 --- a/lib/models/nutrition/log.g.dart +++ b/lib/models/nutrition/log.g.dart @@ -7,14 +7,8 @@ part of 'log.dart'; // ************************************************************************** Log _$LogFromJson(Map json) { - $checkKeys(json, requiredKeys: const [ - 'id', - 'plan', - 'datetime', - 'ingredient', - 'weight_unit', - 'amount' - ]); + $checkKeys(json, + requiredKeys: const ['id', 'plan', 'datetime', 'ingredient', 'weight_unit', 'amount']); return Log( id: json['id'] as int?, ingredientId: json['ingredient'] as int, diff --git a/lib/models/nutrition/meal_item.dart b/lib/models/nutrition/meal_item.dart index 7f061244..c5a11d98 100644 --- a/lib/models/nutrition/meal_item.dart +++ b/lib/models/nutrition/meal_item.dart @@ -63,8 +63,7 @@ class MealItem { MealItem.empty(); // Boilerplate - factory MealItem.fromJson(Map json) => - _$MealItemFromJson(json); + factory MealItem.fromJson(Map json) => _$MealItemFromJson(json); Map toJson() => _$MealItemToJson(this); diff --git a/lib/models/nutrition/nutritional_plan.dart b/lib/models/nutrition/nutritional_plan.dart index f3cd6ccb..1ab59032 100644 --- a/lib/models/nutrition/nutritional_plan.dart +++ b/lib/models/nutrition/nutritional_plan.dart @@ -59,8 +59,7 @@ class NutritionalPlan { } // Boilerplate - factory NutritionalPlan.fromJson(Map json) => - _$NutritionalPlanFromJson(json); + factory NutritionalPlan.fromJson(Map json) => _$NutritionalPlanFromJson(json); Map toJson() => _$NutritionalPlanToJson(this); /// Calculations @@ -78,8 +77,7 @@ class NutritionalPlan { Map get logEntriesValues { var out = {}; for (var log in logs) { - final date = - DateTime(log.datetime.year, log.datetime.month, log.datetime.day); + final date = DateTime(log.datetime.year, log.datetime.month, log.datetime.day); if (!out.containsKey(date)) { out[date] = NutritionalValues(); diff --git a/lib/models/nutrition/nutritional_plan.g.dart b/lib/models/nutrition/nutritional_plan.g.dart index 8f8e50d2..024e87db 100644 --- a/lib/models/nutrition/nutritional_plan.g.dart +++ b/lib/models/nutrition/nutritional_plan.g.dart @@ -15,8 +15,7 @@ NutritionalPlan _$NutritionalPlanFromJson(Map json) { ); } -Map _$NutritionalPlanToJson(NutritionalPlan instance) => - { +Map _$NutritionalPlanToJson(NutritionalPlan instance) => { 'id': instance.id, 'description': instance.description, 'creation_date': toDate(instance.creationDate), diff --git a/lib/models/nutrition/weight_unit.dart b/lib/models/nutrition/weight_unit.dart index b943d607..3bcab86e 100644 --- a/lib/models/nutrition/weight_unit.dart +++ b/lib/models/nutrition/weight_unit.dart @@ -34,7 +34,6 @@ class WeightUnit { }); // Boilerplate - factory WeightUnit.fromJson(Map json) => - _$WeightUnitFromJson(json); + factory WeightUnit.fromJson(Map json) => _$WeightUnitFromJson(json); Map toJson() => _$WeightUnitToJson(this); } diff --git a/lib/models/nutrition/weight_unit.g.dart b/lib/models/nutrition/weight_unit.g.dart index 257d1444..b8a01b2b 100644 --- a/lib/models/nutrition/weight_unit.g.dart +++ b/lib/models/nutrition/weight_unit.g.dart @@ -14,8 +14,7 @@ WeightUnit _$WeightUnitFromJson(Map json) { ); } -Map _$WeightUnitToJson(WeightUnit instance) => - { +Map _$WeightUnitToJson(WeightUnit instance) => { 'id': instance.id, 'name': instance.name, }; diff --git a/lib/models/workouts/day.dart b/lib/models/workouts/day.dart index c098d1c8..1ca783c2 100644 --- a/lib/models/workouts/day.dart +++ b/lib/models/workouts/day.dart @@ -75,8 +75,7 @@ class Day { final now = DateTime.now(); final firstDayOfWeek = now.subtract(Duration(days: now.weekday)); - return DateFormat(DateFormat.WEEKDAY, locale) - .format(firstDayOfWeek.add(Duration(days: day))); + return DateFormat(DateFormat.WEEKDAY, locale).format(firstDayOfWeek.add(Duration(days: day))); } // Boilerplate diff --git a/lib/models/workouts/day.g.dart b/lib/models/workouts/day.g.dart index 9d261015..6ab6e972 100644 --- a/lib/models/workouts/day.g.dart +++ b/lib/models/workouts/day.g.dart @@ -7,8 +7,7 @@ part of 'day.dart'; // ************************************************************************** Day _$DayFromJson(Map json) { - $checkKeys(json, - requiredKeys: const ['id', 'training', 'description', 'day']); + $checkKeys(json, requiredKeys: const ['id', 'training', 'description', 'day']); return Day() ..id = json['id'] as int? ..workoutId = json['training'] as int diff --git a/lib/models/workouts/log.dart b/lib/models/workouts/log.dart index 7b66e6f2..bfc30fa0 100644 --- a/lib/models/workouts/log.dart +++ b/lib/models/workouts/log.dart @@ -112,8 +112,7 @@ class Log { /// Returns the text representation for a single setting, used in the gym mode String get singleLogRepTextNoNl { - return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir) - .replaceAll('\n', ''); + return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir).replaceAll('\n', ''); } /// Override the equals operator @@ -131,8 +130,7 @@ class Log { } @override - int get hashCode => - hashValues(exerciseId, weight, weightUnitId, reps, repetitionUnitId, rir); + int get hashCode => hashValues(exerciseId, weight, weightUnitId, reps, repetitionUnitId, rir); //@override //int get hashCode => super.hashCode; diff --git a/lib/models/workouts/repetition_unit.dart b/lib/models/workouts/repetition_unit.dart index feedcce6..a732c9a1 100644 --- a/lib/models/workouts/repetition_unit.dart +++ b/lib/models/workouts/repetition_unit.dart @@ -34,7 +34,6 @@ class RepetitionUnit { }); // Boilerplate - factory RepetitionUnit.fromJson(Map json) => - _$RepetitionUnitFromJson(json); + factory RepetitionUnit.fromJson(Map json) => _$RepetitionUnitFromJson(json); Map toJson() => _$RepetitionUnitToJson(this); } diff --git a/lib/models/workouts/repetition_unit.g.dart b/lib/models/workouts/repetition_unit.g.dart index 86c481bd..40829256 100644 --- a/lib/models/workouts/repetition_unit.g.dart +++ b/lib/models/workouts/repetition_unit.g.dart @@ -14,8 +14,7 @@ RepetitionUnit _$RepetitionUnitFromJson(Map json) { ); } -Map _$RepetitionUnitToJson(RepetitionUnit instance) => - { +Map _$RepetitionUnitToJson(RepetitionUnit instance) => { 'id': instance.id, 'name': instance.name, }; diff --git a/lib/models/workouts/session.dart b/lib/models/workouts/session.dart index 430a3513..cdb3f130 100644 --- a/lib/models/workouts/session.dart +++ b/lib/models/workouts/session.dart @@ -41,18 +41,10 @@ class WorkoutSession { @JsonKey(required: false, defaultValue: '') late String notes; - @JsonKey( - required: true, - name: 'time_start', - toJson: timeToString, - fromJson: stringToTime) + @JsonKey(required: true, name: 'time_start', toJson: timeToString, fromJson: stringToTime) late TimeOfDay timeStart; - @JsonKey( - required: true, - name: 'time_end', - toJson: timeToString, - fromJson: stringToTime) + @JsonKey(required: true, name: 'time_end', toJson: timeToString, fromJson: stringToTime) late TimeOfDay timeEnd; WorkoutSession(); @@ -68,8 +60,7 @@ class WorkoutSession { }); // Boilerplate - factory WorkoutSession.fromJson(Map json) => - _$WorkoutSessionFromJson(json); + factory WorkoutSession.fromJson(Map json) => _$WorkoutSessionFromJson(json); Map toJson() => _$WorkoutSessionToJson(this); get impressionAsString { diff --git a/lib/models/workouts/session.g.dart b/lib/models/workouts/session.g.dart index eae1b04d..b00ec0c2 100644 --- a/lib/models/workouts/session.g.dart +++ b/lib/models/workouts/session.g.dart @@ -7,14 +7,8 @@ part of 'session.dart'; // ************************************************************************** WorkoutSession _$WorkoutSessionFromJson(Map json) { - $checkKeys(json, requiredKeys: const [ - 'id', - 'workout', - 'date', - 'impression', - 'time_start', - 'time_end' - ]); + $checkKeys(json, + requiredKeys: const ['id', 'workout', 'date', 'impression', 'time_start', 'time_end']); return WorkoutSession() ..id = json['id'] as int? ..workoutId = json['workout'] as int @@ -25,8 +19,7 @@ WorkoutSession _$WorkoutSessionFromJson(Map json) { ..timeEnd = stringToTime(json['time_end'] as String?); } -Map _$WorkoutSessionToJson(WorkoutSession instance) => - { +Map _$WorkoutSessionToJson(WorkoutSession instance) => { 'id': instance.id, 'workout': instance.workoutId, 'date': toDate(instance.date), diff --git a/lib/models/workouts/set.dart b/lib/models/workouts/set.dart index c9f43af8..22742dc6 100644 --- a/lib/models/workouts/set.dart +++ b/lib/models/workouts/set.dart @@ -109,9 +109,7 @@ class Set { /// Returns all settings for the given exercise List filterSettingsByExercise(Exercise exercise) { - return settings - .where((element) => element.exerciseId == exercise.id) - .toList(); + return settings.where((element) => element.exerciseId == exercise.id).toList(); } /// Returns a list with all repetitions for the given exercise diff --git a/lib/models/workouts/setting.dart b/lib/models/workouts/setting.dart index 73bf86e0..e9df77e1 100644 --- a/lib/models/workouts/setting.dart +++ b/lib/models/workouts/setting.dart @@ -29,18 +29,7 @@ part 'setting.g.dart'; class Setting { /// Allowed RiR values. This list must be kept in sync with RIR_OPTIONS in the /// wger server - static const POSSIBLE_RIR_VALUES = [ - '', - '0', - '0.5', - '1', - '1.5', - '2', - '2.5', - '3', - '3.5', - '4' - ]; + static const POSSIBLE_RIR_VALUES = ['', '0', '0.5', '1', '1.5', '2', '2.5', '3', '3.5', '4']; static const DEFAULT_RIR = ''; @JsonKey(required: true) @@ -99,8 +88,7 @@ class Setting { Setting.empty(); // Boilerplate - factory Setting.fromJson(Map json) => - _$SettingFromJson(json); + factory Setting.fromJson(Map json) => _$SettingFromJson(json); Map toJson() => _$SettingToJson(this); set exercise(Exercise exercise) { diff --git a/lib/models/workouts/weight_unit.dart b/lib/models/workouts/weight_unit.dart index edb94b1f..82463c75 100644 --- a/lib/models/workouts/weight_unit.dart +++ b/lib/models/workouts/weight_unit.dart @@ -34,7 +34,6 @@ class WeightUnit { }); // Boilerplate - factory WeightUnit.fromJson(Map json) => - _$WeightUnitFromJson(json); + factory WeightUnit.fromJson(Map json) => _$WeightUnitFromJson(json); Map toJson() => _$WeightUnitToJson(this); } diff --git a/lib/models/workouts/weight_unit.g.dart b/lib/models/workouts/weight_unit.g.dart index 257d1444..b8a01b2b 100644 --- a/lib/models/workouts/weight_unit.g.dart +++ b/lib/models/workouts/weight_unit.g.dart @@ -14,8 +14,7 @@ WeightUnit _$WeightUnitFromJson(Map json) { ); } -Map _$WeightUnitToJson(WeightUnit instance) => - { +Map _$WeightUnitToJson(WeightUnit instance) => { 'id': instance.id, 'name': instance.name, }; diff --git a/lib/models/workouts/workout_plan.dart b/lib/models/workouts/workout_plan.dart index 4c72e1cf..110989c6 100644 --- a/lib/models/workouts/workout_plan.dart +++ b/lib/models/workouts/workout_plan.dart @@ -65,8 +65,7 @@ class WorkoutPlan { } // Boilerplate - factory WorkoutPlan.fromJson(Map json) => - _$WorkoutPlanFromJson(json); + factory WorkoutPlan.fromJson(Map json) => _$WorkoutPlanFromJson(json); Map toJson() => _$WorkoutPlanToJson(this); /// Filters the workout logs by exercise and sorts them by date @@ -76,8 +75,7 @@ class WorkoutPlan { /// reps, etc. are considered equal. Workout ID, Log ID and date are not /// considered. List filterLogsByExercise(Exercise exercise, {bool unique = false}) { - var out = - logs.where((element) => element.exerciseId == exercise.id).toList(); + var out = logs.where((element) => element.exerciseId == exercise.id).toList(); if (unique) { out = out.toSet().toList(); diff --git a/lib/models/workouts/workout_plan.g.dart b/lib/models/workouts/workout_plan.g.dart index 412986f2..0a1dfb0a 100644 --- a/lib/models/workouts/workout_plan.g.dart +++ b/lib/models/workouts/workout_plan.g.dart @@ -7,8 +7,7 @@ part of 'workout_plan.dart'; // ************************************************************************** WorkoutPlan _$WorkoutPlanFromJson(Map json) { - $checkKeys(json, - requiredKeys: const ['id', 'creation_date', 'name', 'description']); + $checkKeys(json, requiredKeys: const ['id', 'creation_date', 'name', 'description']); return WorkoutPlan( id: json['id'] as int?, creationDate: DateTime.parse(json['creation_date'] as String), @@ -17,8 +16,7 @@ WorkoutPlan _$WorkoutPlanFromJson(Map json) { ); } -Map _$WorkoutPlanToJson(WorkoutPlan instance) => - { +Map _$WorkoutPlanToJson(WorkoutPlan instance) => { 'id': instance.id, 'creation_date': instance.creationDate.toIso8601String(), 'name': instance.name, diff --git a/lib/providers/base_provider.dart b/lib/providers/base_provider.dart index a013822a..c60e57cd 100644 --- a/lib/providers/base_provider.dart +++ b/lib/providers/base_provider.dart @@ -38,8 +38,7 @@ class WgerBaseProvider { } /// Helper function to make a URL. - Uri makeUrl(String path, - {int? id, String? objectMethod, Map? query}) { + Uri makeUrl(String path, {int? id, String? objectMethod, Map? query}) { return makeUri(auth.serverUrl!, path, id, objectMethod, query); } diff --git a/lib/providers/body_weight.dart b/lib/providers/body_weight.dart index 0fa1f853..5d6461f3 100644 --- a/lib/providers/body_weight.dart +++ b/lib/providers/body_weight.dart @@ -27,8 +27,7 @@ class BodyWeightProvider extends WgerBaseProvider with ChangeNotifier { static const bodyWeightUrl = 'weightentry'; List _entries = []; - BodyWeightProvider(AuthProvider auth, List entries, - [http.Client? client]) + BodyWeightProvider(AuthProvider auth, List entries, [http.Client? client]) : this._entries = entries, super(auth, client); @@ -55,8 +54,7 @@ class BodyWeightProvider extends WgerBaseProvider with ChangeNotifier { Future> fetchAndSetEntries() async { // Process the response - final data = - await fetch(makeUrl(bodyWeightUrl, query: {'ordering': '-date'})); + final data = await fetch(makeUrl(bodyWeightUrl, query: {'ordering': '-date'})); final List loadedEntries = []; for (final entry in data['results']) { loadedEntries.add(WeightEntry.fromJson(entry)); @@ -85,8 +83,7 @@ class BodyWeightProvider extends WgerBaseProvider with ChangeNotifier { Future deleteEntry(int id) async { // Send the request and remove the entry from the list... - final existingEntryIndex = - _entries.indexWhere((element) => element.id == id); + final existingEntryIndex = _entries.indexWhere((element) => element.id == id); var existingWeightEntry = _entries[existingEntryIndex]; _entries.removeAt(existingEntryIndex); notifyListeners(); diff --git a/lib/providers/exercises.dart b/lib/providers/exercises.dart index 76d95390..cb305fdf 100644 --- a/lib/providers/exercises.dart +++ b/lib/providers/exercises.dart @@ -51,8 +51,7 @@ class ExercisesProvider extends WgerBaseProvider with ChangeNotifier { List _muscles = []; List _equipment = []; - ExercisesProvider(AuthProvider auth, List entries, - [http.Client? client]) + ExercisesProvider(AuthProvider auth, List entries, [http.Client? client]) : this._exercises = entries, super(auth, client); @@ -130,14 +129,10 @@ class ExercisesProvider extends WgerBaseProvider with ChangeNotifier { if (prefs.containsKey(PREFS_EXERCISES)) { final exerciseData = json.decode(prefs.getString(PREFS_EXERCISES)!); if (DateTime.parse(exerciseData['expiresIn']).isAfter(DateTime.now())) { - exerciseData['exercises'] - .forEach((e) => _exercises.add(Exercise.fromJson(e))); - exerciseData['equipment'] - .forEach((e) => _equipment.add(Equipment.fromJson(e))); - exerciseData['muscles'] - .forEach((e) => _muscles.add(Muscle.fromJson(e))); - exerciseData['categories'] - .forEach((e) => _categories.add(ExerciseCategory.fromJson(e))); + exerciseData['exercises'].forEach((e) => _exercises.add(Exercise.fromJson(e))); + exerciseData['equipment'].forEach((e) => _equipment.add(Equipment.fromJson(e))); + exerciseData['muscles'].forEach((e) => _muscles.add(Muscle.fromJson(e))); + exerciseData['categories'].forEach((e) => _categories.add(ExerciseCategory.fromJson(e))); log("Read ${exerciseData['exercises'].length} exercises from cache. Valid till ${exerciseData['expiresIn']}"); return; } @@ -156,19 +151,16 @@ class ExercisesProvider extends WgerBaseProvider with ChangeNotifier { headers: { HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8', }); - final exercisesData = - json.decode(utf8.decode(response.bodyBytes)) as Map; + final exercisesData = json.decode(utf8.decode(response.bodyBytes)) as Map; try { // Load exercises - exercisesData['results'] - .forEach((e) => _exercises.add(Exercise.fromJson(e))); + exercisesData['results'].forEach((e) => _exercises.add(Exercise.fromJson(e))); // Save the result to the cache final exerciseData = { 'date': DateTime.now().toIso8601String(), - 'expiresIn': - DateTime.now().add(Duration(days: daysToCache)).toIso8601String(), + 'expiresIn': DateTime.now().add(Duration(days: daysToCache)).toIso8601String(), 'exercises': _exercises.map((e) => e.toJson()).toList(), 'equipment': _equipment.map((e) => e.toJson()).toList(), 'categories': _categories.map((e) => e.toJson()).toList(), @@ -210,8 +202,7 @@ class ExercisesProvider extends WgerBaseProvider with ChangeNotifier { } // Process the response - final result = json.decode(utf8.decode(response.bodyBytes))['suggestions'] - as List; + final result = json.decode(utf8.decode(response.bodyBytes))['suggestions'] as List; for (var entry in result) { entry['exercise_obj'] = await fetchAndSetExercise(entry['data']['id']); } diff --git a/lib/providers/gallery.dart b/lib/providers/gallery.dart index 46b4d70a..e74e6fef 100644 --- a/lib/providers/gallery.dart +++ b/lib/providers/gallery.dart @@ -32,8 +32,7 @@ class GalleryProvider extends WgerBaseProvider with ChangeNotifier { List images = []; - GalleryProvider(AuthProvider auth, List entries, - [http.Client? client]) + GalleryProvider(AuthProvider auth, List entries, [http.Client? client]) : this.images = entries, super(auth, client); @@ -63,8 +62,7 @@ class GalleryProvider extends WgerBaseProvider with ChangeNotifier { HttpHeaders.authorizationHeader: 'Token ${auth.token}', HttpHeaders.userAgentHeader: auth.getAppNameHeader(), }); - request.files - .add(await http.MultipartFile.fromPath('image', imageFile.path)); + request.files.add(await http.MultipartFile.fromPath('image', imageFile.path)); request.fields['date'] = toDate(image.date)!; request.fields['description'] = image.description; @@ -78,8 +76,7 @@ class GalleryProvider extends WgerBaseProvider with ChangeNotifier { } Future editImage(gallery.Image image, PickedFile? imageFile) async { - var request = - http.MultipartRequest('PATCH', makeUrl(_galleryUrlPath, id: image.id)); + var request = http.MultipartRequest('PATCH', makeUrl(_galleryUrlPath, id: image.id)); request.headers.addAll({ HttpHeaders.authorizationHeader: 'Token ${auth.token}', HttpHeaders.userAgentHeader: auth.getAppNameHeader(), @@ -87,8 +84,7 @@ class GalleryProvider extends WgerBaseProvider with ChangeNotifier { // Only send the image if a new one was selected if (imageFile != null) { - request.files - .add(await http.MultipartFile.fromPath('image', imageFile.path)); + request.files.add(await http.MultipartFile.fromPath('image', imageFile.path)); } // Update image info diff --git a/lib/providers/nutrition.dart b/lib/providers/nutrition.dart index ec5493ca..e14950db 100644 --- a/lib/providers/nutrition.dart +++ b/lib/providers/nutrition.dart @@ -45,8 +45,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { List _plans = []; List _ingredients = []; - NutritionPlansProvider(AuthProvider auth, List entries, - [http.Client? client]) + NutritionPlansProvider(AuthProvider auth, List entries, [http.Client? client]) : this._plans = entries, super(auth, client); @@ -85,8 +84,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { /// Fetches and sets all plans sparsely, i.e. only with the data on the plan /// object itself and no child attributes Future fetchAndSetAllPlansSparse() async { - final data = - await fetch(makeUrl(_nutritionalPlansPath, query: {'limit': '1000'})); + final data = await fetch(makeUrl(_nutritionalPlansPath, query: {'limit': '1000'})); for (final planData in data['results']) { final plan = NutritionalPlan.fromJson(planData); _plans.add(plan); @@ -127,8 +125,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { } // Plan - final fullPlanData = - await fetch(makeUrl(_nutritionalPlansInfoPath, id: planId)); + final fullPlanData = await fetch(makeUrl(_nutritionalPlansInfoPath, id: planId)); // Meals List meals = []; @@ -286,8 +283,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { if (prefs.containsKey('ingredientData')) { final ingredientData = json.decode(prefs.getString('ingredientData')!); if (DateTime.parse(ingredientData['expiresIn']).isAfter(DateTime.now())) { - ingredientData['ingredients'] - .forEach((e) => _ingredients.add(Ingredient.fromJson(e))); + ingredientData['ingredients'].forEach((e) => _ingredients.add(Ingredient.fromJson(e))); log("Read ${ingredientData['ingredients'].length} ingredients from cache. Valid till ${ingredientData['expiresIn']}"); return; } @@ -296,8 +292,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { // Initialise an empty cache final ingredientData = { 'date': DateTime.now().toIso8601String(), - 'expiresIn': - DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(), + 'expiresIn': DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(), 'ingredients': [] }; prefs.setString('ingredientData', json.encode(ingredientData)); @@ -305,8 +300,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { } /// Searches for an ingredient - Future searchIngredient(String name, - [String languageCode = 'en']) async { + Future searchIngredient(String name, [String languageCode = 'en']) async { if (name.length <= 1) { return []; } @@ -329,8 +323,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { } // Process the response - return json.decode(utf8.decode(response.bodyBytes))['suggestions'] - as List; + return json.decode(utf8.decode(response.bodyBytes))['suggestions'] as List; } /// Log meal to nutrition diary @@ -350,8 +343,7 @@ class NutritionPlansProvider extends WgerBaseProvider with ChangeNotifier { Future fetchAndSetLogs(NutritionalPlan plan) async { // TODO: update fetch to that it can use the pagination final data = await fetch( - makeUrl(_nutritionDiaryPath, - query: {'plan': plan.id.toString(), 'limit': '1000'}), + makeUrl(_nutritionDiaryPath, query: {'plan': plan.id.toString(), 'limit': '1000'}), ); for (var logData in data['results']) { diff --git a/lib/providers/workout_plans.dart b/lib/providers/workout_plans.dart index df9ef6c3..4078c972 100644 --- a/lib/providers/workout_plans.dart +++ b/lib/providers/workout_plans.dart @@ -53,8 +53,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { List _weightUnits = []; List _repetitionUnit = []; - WorkoutPlansProvider( - AuthProvider auth, ExercisesProvider exercises, List entries, + WorkoutPlansProvider(AuthProvider auth, ExercisesProvider exercises, List entries, [http.Client? client]) : this._exercises = exercises, this._workoutPlans = entries, @@ -78,8 +77,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { /// Return the default weight unit (kg) WeightUnit get defaultWeightUnit { - return _weightUnits - .firstWhere((element) => element.id == DEFAULT_WEIGHT_UNIT); + return _weightUnits.firstWhere((element) => element.id == DEFAULT_WEIGHT_UNIT); } List get repetitionUnits { @@ -88,8 +86,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { /// Return the default weight unit (reps) RepetitionUnit get defaultRepetitionUnit { - return _repetitionUnit - .firstWhere((element) => element.id == DEFAULT_REPETITION_UNIT); + return _repetitionUnit.firstWhere((element) => element.id == DEFAULT_REPETITION_UNIT); } WorkoutPlan findById(int id) { @@ -144,8 +141,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { /// Fetches all workout plan sparsely, i.e. only with the data on the plan /// object itself and no child attributes Future fetchAndSetAllPlansSparse() async { - final data = - await fetch(makeUrl(_workoutPlansUrlPath, query: {'limit': '1000'})); + final data = await fetch(makeUrl(_workoutPlansUrlPath, query: {'limit': '1000'})); for (final workoutPlanData in data['results']) { final plan = WorkoutPlan.fromJson(workoutPlanData); _workoutPlans.add(plan); @@ -187,8 +183,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { // Plan final fullPlanData = await fetch( - makeUrl(_workoutPlansUrlPath, - id: workoutId, objectMethod: 'canonical_representation'), + makeUrl(_workoutPlansUrlPath, id: workoutId, objectMethod: 'canonical_representation'), ); // Days @@ -205,14 +200,12 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { // Settings List settings = []; - final settingData = - allSettingsData['results'].where((s) => s['set'] == workoutSet.id); + final settingData = allSettingsData['results'].where((s) => s['set'] == workoutSet.id); for (final settingEntry in settingData) { final workoutSetting = Setting.fromJson(settingEntry); - workoutSetting.exercise = - await _exercises.fetchAndSetExercise(workoutSetting.exerciseId); + workoutSetting.exercise = await _exercises.fetchAndSetExercise(workoutSetting.exerciseId); workoutSetting.weightUnit = _weightUnits.firstWhere( (e) => e.id == workoutSetting.weightUnitId, ); @@ -251,10 +244,8 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { for (final entry in logData['results']) { try { var log = Log.fromJson(entry); - log.weightUnit = - _weightUnits.firstWhere((e) => e.id == log.weightUnitId); - log.repetitionUnit = - _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId); + log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId); + log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId); log.exercise = await _exercises.fetchAndSetExercise(log.exerciseId); plan.logs.add(log); } catch (e) { @@ -284,14 +275,12 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { } Future editWorkout(WorkoutPlan workout) async { - await patch( - workout.toJson(), makeUrl(_workoutPlansUrlPath, id: workout.id)); + await patch(workout.toJson(), makeUrl(_workoutPlansUrlPath, id: workout.id)); notifyListeners(); } Future deleteWorkout(int id) async { - final existingWorkoutIndex = - _workoutPlans.indexWhere((element) => element.id == id); + final existingWorkoutIndex = _workoutPlans.indexWhere((element) => element.id == id); var existingWorkout = _workoutPlans[existingWorkoutIndex]; _workoutPlans.removeAt(existingWorkoutIndex); notifyListeners(); @@ -305,8 +294,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { } } - Future> fetchLogData( - WorkoutPlan workout, Exercise exercise) async { + Future> fetchLogData(WorkoutPlan workout, Exercise exercise) async { final data = await fetch( makeUrl( _workoutPlansUrlPath, @@ -356,8 +344,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { unitData['weightUnit'].forEach( (e) => _weightUnits.add(WeightUnit.fromJson(e)), ); - dev.log( - "Read workout units data from cache. Valid till ${unitData['expiresIn']}"); + dev.log("Read workout units data from cache. Valid till ${unitData['expiresIn']}"); return; } } @@ -369,8 +356,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { // Save the result to the cache final exerciseData = { 'date': DateTime.now().toIso8601String(), - 'expiresIn': - DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(), + 'expiresIn': DateTime.now().add(Duration(days: DAYS_TO_CACHE)).toIso8601String(), 'repetitionUnits': _repetitionUnit.map((e) => e.toJson()).toList(), 'weightUnit': _weightUnits.map((e) => e.toJson()).toList(), }; @@ -501,8 +487,7 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { log.id = newLog.id; log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId); - log.repetitionUnit = - _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId); + log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId); log.exercise = await _exercises.fetchAndSetExercise(log.exerciseId); final plan = findById(log.workoutPlan); diff --git a/lib/screens/auth_screen.dart b/lib/screens/auth_screen.dart index e68521f9..5b922c89 100644 --- a/lib/screens/auth_screen.dart +++ b/lib/screens/auth_screen.dart @@ -56,8 +56,7 @@ class AuthScreen extends StatelessWidget { ), Container( margin: EdgeInsets.only(bottom: 20.0), - padding: - EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0), + padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0), child: Text( 'WGER', style: TextStyle( @@ -208,8 +207,7 @@ class _AuthCardState extends State { if (_authMode == AuthMode.Signup) TextFormField( key: Key('inputEmail'), - decoration: InputDecoration( - labelText: AppLocalizations.of(context).email), + decoration: InputDecoration(labelText: AppLocalizations.of(context).email), autofillHints: [AutofillHints.email], controller: _emailController, keyboardType: TextInputType.emailAddress, @@ -228,8 +226,7 @@ class _AuthCardState extends State { ), TextFormField( key: Key('inputPassword'), - decoration: InputDecoration( - labelText: AppLocalizations.of(context).password), + decoration: InputDecoration(labelText: AppLocalizations.of(context).password), autofillHints: [AutofillHints.password], obscureText: true, controller: _passwordController, @@ -247,17 +244,15 @@ class _AuthCardState extends State { if (_authMode == AuthMode.Signup) TextFormField( key: Key('inputPassword2'), - decoration: InputDecoration( - labelText: - AppLocalizations.of(context).confirmPassword), + decoration: + InputDecoration(labelText: AppLocalizations.of(context).confirmPassword), controller: _password2Controller, enabled: _authMode == AuthMode.Signup, obscureText: true, validator: _authMode == AuthMode.Signup ? (value) { if (value != _passwordController.text) { - return AppLocalizations.of(context) - .passwordsDontMatch; + return AppLocalizations.of(context).passwordsDontMatch; } return null; } @@ -274,10 +269,8 @@ class _AuthCardState extends State { child: TextFormField( key: Key('inputServer'), decoration: InputDecoration( - labelText: AppLocalizations.of(context) - .customServerUrl, - helperText: AppLocalizations.of(context) - .customServerHint, + labelText: AppLocalizations.of(context).customServerUrl, + helperText: AppLocalizations.of(context).customServerHint, helperMaxLines: 4), controller: _serverUrlController, validator: (value) { @@ -332,12 +325,8 @@ class _AuthCardState extends State { key: Key('toggleActionButton'), child: Text( _authMode == AuthMode.Login - ? AppLocalizations.of(context) - .registerInstead - .toUpperCase() - : AppLocalizations.of(context) - .loginInstead - .toUpperCase(), + ? AppLocalizations.of(context).registerInstead.toUpperCase() + : AppLocalizations.of(context).loginInstead.toUpperCase(), ), onPressed: _switchAuthMode, ), diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 5caf65fb..8e23ec7b 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -53,16 +53,11 @@ class _DashboardScreenState extends State { if (!Provider.of(context, listen: false).dataInit) { Provider.of(context, listen: false).setServerVersion(); - final workoutPlansProvider = - Provider.of(context, listen: false); - final nutritionPlansProvider = - Provider.of(context, listen: false); - final exercisesProvider = - Provider.of(context, listen: false); - final galleryProvider = - Provider.of(context, listen: false); - final weightProvider = - Provider.of(context, listen: false); + final workoutPlansProvider = Provider.of(context, listen: false); + final nutritionPlansProvider = Provider.of(context, listen: false); + final exercisesProvider = Provider.of(context, listen: false); + final galleryProvider = Provider.of(context, listen: false); + final weightProvider = Provider.of(context, listen: false); // Base data await Future.wait([ diff --git a/lib/screens/home_tabs_screen.dart b/lib/screens/home_tabs_screen.dart index 3e7e7aeb..ec64217a 100644 --- a/lib/screens/home_tabs_screen.dart +++ b/lib/screens/home_tabs_screen.dart @@ -33,8 +33,7 @@ class HomeTabsScreen extends StatefulWidget { _HomeTabsScreenState createState() => _HomeTabsScreenState(); } -class _HomeTabsScreenState extends State - with SingleTickerProviderStateMixin { +class _HomeTabsScreenState extends State with SingleTickerProviderStateMixin { int _selectedIndex = 0; void _onItemTapped(int index) { diff --git a/lib/screens/nutritional_plan_screen.dart b/lib/screens/nutritional_plan_screen.dart index b6a9427e..9c244732 100644 --- a/lib/screens/nutritional_plan_screen.dart +++ b/lib/screens/nutritional_plan_screen.dart @@ -34,16 +34,14 @@ enum NutritionalPlanOptions { class NutritionalPlanScreen extends StatelessWidget { static const routeName = '/nutritional-plan-detail'; - Future _loadFullPlan( - BuildContext context, int planId) async { + Future _loadFullPlan(BuildContext context, int planId) async { return await Provider.of(context, listen: false) .fetchAndSetPlanFull(planId); } @override Widget build(BuildContext context) { - final _nutritionalPlan = - ModalRoute.of(context)!.settings.arguments as NutritionalPlan; + final _nutritionalPlan = ModalRoute.of(context)!.settings.arguments as NutritionalPlan; return Scaffold( //appBar: getAppBar(nutritionalPlan), @@ -93,8 +91,7 @@ class NutritionalPlanScreen extends StatelessWidget { flexibleSpace: FlexibleSpaceBar( title: Text(_nutritionalPlan.description), background: Image( - image: AssetImage( - 'assets/images/backgrounds/nutritional_plans.jpg'), + image: AssetImage('assets/images/backgrounds/nutritional_plans.jpg'), fit: BoxFit.cover, ), ), diff --git a/lib/screens/nutritional_plans_screen.dart b/lib/screens/nutritional_plans_screen.dart index e86ae3a3..5ca0a419 100644 --- a/lib/screens/nutritional_plans_screen.dart +++ b/lib/screens/nutritional_plans_screen.dart @@ -46,8 +46,7 @@ class NutritionScreen extends StatelessWidget { }, ), body: Consumer( - builder: (context, nutritionProvider, child) => - NutritionalPlansList(nutritionProvider), + builder: (context, nutritionProvider, child) => NutritionalPlansList(nutritionProvider), ), ); } diff --git a/lib/screens/workout_plan_screen.dart b/lib/screens/workout_plan_screen.dart index 82309aad..212bb6e3 100644 --- a/lib/screens/workout_plan_screen.dart +++ b/lib/screens/workout_plan_screen.dart @@ -70,8 +70,7 @@ class _WorkoutPlanScreenState extends State { @override Widget build(BuildContext context) { - final workoutPlan = - ModalRoute.of(context)!.settings.arguments as WorkoutPlan; + final workoutPlan = ModalRoute.of(context)!.settings.arguments as WorkoutPlan; return Scaffold( body: CustomScrollView( @@ -82,8 +81,7 @@ class _WorkoutPlanScreenState extends State { flexibleSpace: FlexibleSpaceBar( title: Text(workoutPlan.name), background: Image( - image: - AssetImage('assets/images/backgrounds/workout_plans.jpg'), + image: AssetImage('assets/images/backgrounds/workout_plans.jpg'), fit: BoxFit.cover, ), ), @@ -129,8 +127,7 @@ class _WorkoutPlanScreenState extends State { ), FutureBuilder( future: _loadFullWorkout(context, workoutPlan.id!), - builder: (context, AsyncSnapshot snapshot) => - SliverList( + builder: (context, AsyncSnapshot snapshot) => SliverList( delegate: SliverChildListDelegate( [ snapshot.connectionState == ConnectionState.waiting @@ -141,8 +138,7 @@ class _WorkoutPlanScreenState extends State { ), ) : Consumer( - builder: (context, value, child) => - getBody(workoutPlan), + builder: (context, value, child) => getBody(workoutPlan), ), ], ), diff --git a/lib/screens/workout_plans_screen.dart b/lib/screens/workout_plans_screen.dart index 936b19b0..a4412581 100644 --- a/lib/screens/workout_plans_screen.dart +++ b/lib/screens/workout_plans_screen.dart @@ -50,8 +50,7 @@ class WorkoutPlansScreen extends StatelessWidget { }, ), body: Consumer( - builder: (context, workoutProvider, child) => - WorkoutPlansList(workoutProvider), + builder: (context, workoutProvider, child) => WorkoutPlansList(workoutProvider), ), ); } diff --git a/lib/theme/theme.dart b/lib/theme/theme.dart index bd036080..b30cff7d 100644 --- a/lib/theme/theme.dart +++ b/lib/theme/theme.dart @@ -30,10 +30,8 @@ const Color wgerTextMuted = Colors.black38; const Color wgerBackground = Color(0xfff4f4f6); // Chart colors -const charts.Color wgerChartPrimaryColor = - charts.Color(r: 0x2a, g: 0x4c, b: 0x7d); -const charts.Color wgerChartSecondaryColor = - charts.Color(r: 0xe6, g: 0x39, b: 0x46); +const charts.Color wgerChartPrimaryColor = charts.Color(r: 0x2a, g: 0x4c, b: 0x7d); +const charts.Color wgerChartSecondaryColor = charts.Color(r: 0xe6, g: 0x39, b: 0x46); /// Original sizes for the material text theme /// https://api.flutter.dev/flutter/material/TextTheme-class.html diff --git a/lib/widgets/app_drawer.dart b/lib/widgets/app_drawer.dart index ba813ed1..e6891bb5 100644 --- a/lib/widgets/app_drawer.dart +++ b/lib/widgets/app_drawer.dart @@ -43,8 +43,7 @@ class AppDrawer extends StatelessWidget { onTap: () { Provider.of(context, listen: false).logout(); Provider.of(context, listen: false).clear(); - Provider.of(context, listen: false) - .clear(); + Provider.of(context, listen: false).clear(); Provider.of(context, listen: false).clear(); Provider.of(context, listen: false).clear(); Navigator.of(context).pop(); diff --git a/lib/widgets/core/about.dart b/lib/widgets/core/about.dart index 55349a67..d5373019 100644 --- a/lib/widgets/core/about.dart +++ b/lib/widgets/core/about.dart @@ -68,8 +68,7 @@ class WgerAboutListTile extends StatelessWidget { ], ), contentPadding: EdgeInsets.zero, - onTap: () async => - _launchURL("https://github.com/wger-project", context), + onTap: () async => _launchURL("https://github.com/wger-project", context), ), SizedBox(height: 10), ListTile( @@ -86,9 +85,8 @@ class WgerAboutListTile extends StatelessWidget { ], ), contentPadding: EdgeInsets.zero, - onTap: () async => _launchURL( - 'https://github.com/wger-project/flutter/issues/new/choose', - context), + onTap: () async => + _launchURL('https://github.com/wger-project/flutter/issues/new/choose', context), ), SizedBox(height: 10), ListTile( @@ -122,8 +120,7 @@ class WgerAboutListTile extends StatelessWidget { ], ), contentPadding: EdgeInsets.zero, - onTap: () async => - _launchURL('https://hosted.weblate.org/engage/wger/', context), + onTap: () async => _launchURL('https://hosted.weblate.org/engage/wger/', context), ), ], ); diff --git a/lib/widgets/core/app_bar.dart b/lib/widgets/core/app_bar.dart index 32a00a2f..ccda920b 100644 --- a/lib/widgets/core/app_bar.dart +++ b/lib/widgets/core/app_bar.dart @@ -47,8 +47,7 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget { title: Text(AppLocalizations.of(context).optionsLabel), actions: [ TextButton( - child: Text( - MaterialLocalizations.of(context).closeButtonLabel), + child: Text(MaterialLocalizations.of(context).closeButtonLabel), onPressed: () { Navigator.of(context).pop(); }, @@ -64,19 +63,11 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget { leading: Icon(Icons.exit_to_app), title: Text(AppLocalizations.of(context).logout), onTap: () { - Provider.of(context, listen: false) - .logout(); - Provider.of(context, - listen: false) - .clear(); - Provider.of(context, - listen: false) - .clear(); - Provider.of(context, - listen: false) - .clear(); - Provider.of(context, listen: false) - .clear(); + Provider.of(context, listen: false).logout(); + Provider.of(context, listen: false).clear(); + Provider.of(context, listen: false).clear(); + Provider.of(context, listen: false).clear(); + Provider.of(context, listen: false).clear(); Navigator.of(context).pop(); Navigator.of(context).pushReplacementNamed('/'); }, diff --git a/lib/widgets/dashboard/calendar.dart b/lib/widgets/dashboard/calendar.dart index 14922838..b04c2379 100644 --- a/lib/widgets/dashboard/calendar.dart +++ b/lib/widgets/dashboard/calendar.dart @@ -57,16 +57,15 @@ class DashboardCalendarWidget extends StatefulWidget { DashboardCalendarWidget(); @override - _DashboardCalendarWidgetState createState() => - _DashboardCalendarWidgetState(); + _DashboardCalendarWidgetState createState() => _DashboardCalendarWidgetState(); } class _DashboardCalendarWidgetState extends State with TickerProviderStateMixin { late Map> _events; late final ValueNotifier> _selectedEvents; - RangeSelectionMode _rangeSelectionMode = RangeSelectionMode - .toggledOff; // Can be toggled on/off by longpressing a date + RangeSelectionMode _rangeSelectionMode = + RangeSelectionMode.toggledOff; // Can be toggled on/off by longpressing a date DateTime _focusedDay = DateTime.now(); DateTime? _selectedDay; DateTime? _rangeStart; @@ -84,8 +83,7 @@ class _DashboardCalendarWidgetState extends State void loadEvents() async { // Process weight entries - BodyWeightProvider weightProvider = - Provider.of(context, listen: false); + BodyWeightProvider weightProvider = Provider.of(context, listen: false); for (var entry in weightProvider.items) { final date = DateFormatLists.format(entry.date); @@ -98,8 +96,7 @@ class _DashboardCalendarWidgetState extends State } // Process workout sessions - WorkoutPlansProvider plans = - Provider.of(context, listen: false); + WorkoutPlansProvider plans = Provider.of(context, listen: false); plans.fetchSessionData().then((entries) { for (var entry in entries['results']) { final session = WorkoutSession.fromJson(entry); @@ -109,8 +106,7 @@ class _DashboardCalendarWidgetState extends State } var time = ''; if (session.timeStart != null && session.timeEnd != null) { - time = - '(${timeToString(session.timeStart)} - ${timeToString(session.timeEnd)})'; + time = '(${timeToString(session.timeStart)} - ${timeToString(session.timeEnd)})'; } // Add events to lists @@ -240,12 +236,10 @@ class _DashboardCalendarWidgetState extends State title: Text((() { switch (event.type) { case EventType.caloriesDiary: - return AppLocalizations.of(context) - .nutritionalDiary; + return AppLocalizations.of(context).nutritionalDiary; case EventType.session: - return AppLocalizations.of(context) - .workoutSession; + return AppLocalizations.of(context).workoutSession; case EventType.weight: return AppLocalizations.of(context).weight; diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index b14e1b4c..9d77adaf 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -41,8 +41,7 @@ import 'package:wger/widgets/workouts/forms.dart'; class DashboardNutritionWidget extends StatefulWidget { @override - _DashboardNutritionWidgetState createState() => - _DashboardNutritionWidgetState(); + _DashboardNutritionWidgetState createState() => _DashboardNutritionWidgetState(); } class _DashboardNutritionWidgetState extends State { @@ -53,8 +52,7 @@ class _DashboardNutritionWidgetState extends State { @override void initState() { super.initState(); - _plan = - Provider.of(context, listen: false).currentPlan; + _plan = Provider.of(context, listen: false).currentPlan; _hasContent = _plan != null; } @@ -97,8 +95,7 @@ class _DashboardNutritionWidgetState extends State { icon: Icon(Icons.history_edu), color: wgerPrimaryButtonColor, onPressed: () { - Provider.of(context, listen: false) - .logMealToDiary(meal); + Provider.of(context, listen: false).logMealToDiary(meal); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( @@ -129,8 +126,7 @@ class _DashboardNutritionWidgetState extends State { ), ), SizedBox(width: 5), - Text( - '${item.amount.toStringAsFixed(0)} ${AppLocalizations.of(context).g}'), + Text('${item.amount.toStringAsFixed(0)} ${AppLocalizations.of(context).g}'), ], ), ], @@ -160,9 +156,7 @@ class _DashboardNutritionWidgetState extends State { children: [ ListTile( title: Text( - _hasContent - ? _plan!.description - : AppLocalizations.of(context).labelWorkoutPlan, + _hasContent ? _plan!.description : AppLocalizations.of(context).labelWorkoutPlan, style: Theme.of(context).textTheme.headline4, ), subtitle: Text( @@ -191,8 +185,7 @@ class _DashboardNutritionWidgetState extends State { Container( padding: EdgeInsets.all(15), height: 180, - child: NutritionalPlanPieChartWidget( - _plan!.nutritionalValues), + child: NutritionalPlanPieChartWidget(_plan!.nutritionalValues), ) ], ), @@ -209,9 +202,8 @@ class _DashboardNutritionWidgetState extends State { TextButton( child: Text(AppLocalizations.of(context).goToDetailPage), onPressed: () { - Navigator.of(context).pushNamed( - NutritionalPlanScreen.routeName, - arguments: _plan); + Navigator.of(context) + .pushNamed(NutritionalPlanScreen.routeName, arguments: _plan); }), ], ), @@ -334,8 +326,7 @@ class _DashboardWorkoutWidgetState extends State { icon: Icon(Icons.play_arrow), color: wgerPrimaryButtonColor, onPressed: () { - Navigator.of(context) - .pushNamed(GymModeScreen.routeName, arguments: day); + Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: day); }, ), ], @@ -357,8 +348,7 @@ class _DashboardWorkoutWidgetState extends State { children: [ Text(s.exerciseObj.name), SizedBox(width: 10), - MutedText( - set.getSmartRepr(s.exerciseObj).join('\n')), + MutedText(set.getSmartRepr(s.exerciseObj).join('\n')), ], ), SizedBox(height: 10), @@ -383,9 +373,7 @@ class _DashboardWorkoutWidgetState extends State { children: [ ListTile( title: Text( - _hasContent - ? _workoutPlan!.name - : AppLocalizations.of(context).labelWorkoutPlan, + _hasContent ? _workoutPlan!.name : AppLocalizations.of(context).labelWorkoutPlan, style: Theme.of(context).textTheme.headline4, ), subtitle: Text( @@ -426,8 +414,8 @@ class _DashboardWorkoutWidgetState extends State { TextButton( child: Text(AppLocalizations.of(context).goToDetailPage), onPressed: () { - Navigator.of(context).pushNamed(WorkoutPlanScreen.routeName, - arguments: _workoutPlan); + Navigator.of(context) + .pushNamed(WorkoutPlanScreen.routeName, arguments: _workoutPlan); }, ), ], diff --git a/lib/widgets/exercises/exercises.dart b/lib/widgets/exercises/exercises.dart index b2febf8d..aa31d8b3 100644 --- a/lib/widgets/exercises/exercises.dart +++ b/lib/widgets/exercises/exercises.dart @@ -68,10 +68,7 @@ class ExerciseDetail extends StatelessWidget { style: Theme.of(context).textTheme.headline6, ), if (_exercise.musclesSecondary.length > 0) - Text(_exercise.musclesSecondary - .map((e) => e.name) - .toList() - .join('\n')), + Text(_exercise.musclesSecondary.map((e) => e.name).toList().join('\n')), if (_exercise.musclesSecondary.length == 0) Text('-/-'), SizedBox(height: 8), diff --git a/lib/widgets/gallery/forms.dart b/lib/widgets/gallery/forms.dart index dce5635a..2e7fcbe9 100644 --- a/lib/widgets/gallery/forms.dart +++ b/lib/widgets/gallery/forms.dart @@ -113,8 +113,7 @@ class _ImageFormState extends State { _showPicker(ImageSource.camera); }, leading: Icon(Icons.photo_camera), - title: - Text(AppLocalizations.of(context).takePicture), + title: Text(AppLocalizations.of(context).takePicture), ), ListTile( onTap: () { @@ -122,8 +121,7 @@ class _ImageFormState extends State { _showPicker(ImageSource.gallery); }, leading: Icon(Icons.photo_library), - title: Text(AppLocalizations.of(context) - .chooseFromLibrary)) + title: Text(AppLocalizations.of(context).chooseFromLibrary)) ], ), ); @@ -135,8 +133,7 @@ class _ImageFormState extends State { ), TextFormField( key: Key('field-date'), - decoration: - InputDecoration(labelText: AppLocalizations.of(context).date), + decoration: InputDecoration(labelText: AppLocalizations.of(context).date), controller: dateController, onTap: () async { // Stop keyboard from appearing @@ -165,8 +162,7 @@ class _ImageFormState extends State { ), TextFormField( key: Key('field-description'), - decoration: InputDecoration( - labelText: AppLocalizations.of(context).description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), minLines: 3, maxLines: 10, controller: descriptionController, diff --git a/lib/widgets/gallery/overview.dart b/lib/widgets/gallery/overview.dart index dc138e2c..3fdb0176 100644 --- a/lib/widgets/gallery/overview.dart +++ b/lib/widgets/gallery/overview.dart @@ -53,8 +53,7 @@ class Gallery extends StatelessWidget { child: Column( children: [ Text( - DateFormat.yMd( - Localizations.localeOf(context).languageCode) + DateFormat.yMd(Localizations.localeOf(context).languageCode) .format(currentImage.date), style: Theme.of(context).textTheme.headline5, ), @@ -71,8 +70,7 @@ class Gallery extends StatelessWidget { IconButton( icon: Icon(Icons.delete), onPressed: () { - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .deleteImage(currentImage); Navigator.of(context).pop(); }), diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart index ce4213dc..adcf263b 100644 --- a/lib/widgets/nutrition/charts.dart +++ b/lib/widgets/nutrition/charts.dart @@ -47,10 +47,7 @@ class NutritionalPlanPieChartWidget extends StatelessWidget { data: [ [AppLocalizations.of(context).protein, _nutritionalValues.protein], [AppLocalizations.of(context).fat, _nutritionalValues.fat], - [ - AppLocalizations.of(context).carbohydrates, - _nutritionalValues.carbohydrates - ], + [AppLocalizations.of(context).carbohydrates, _nutritionalValues.carbohydrates], ], labelAccessorFn: (List row, _) => '${row[0]}\n${row[1].toStringAsFixed(0)}${AppLocalizations.of(context).g}', diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index 7c868e3a..25fb30ec 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -52,8 +52,7 @@ class MealForm extends StatelessWidget { children: [ TextFormField( key: Key('field-time'), - decoration: - InputDecoration(labelText: AppLocalizations.of(context).time), + decoration: InputDecoration(labelText: AppLocalizations.of(context).time), controller: _timeController, onTap: () async { // Stop keyboard from appearing @@ -83,12 +82,9 @@ class MealForm extends StatelessWidget { try { _meal.id == null - ? Provider.of(context, - listen: false) + ? Provider.of(context, listen: false) .addMeal(_meal, _planId) - : Provider.of(context, - listen: false) - .editMeal(_meal); + : Provider.of(context, listen: false).editMeal(_meal); } on WgerHttpException catch (error) { showHttpExceptionErrorDialog(error, context); } catch (error) { @@ -128,12 +124,10 @@ class MealItemForm extends StatelessWidget { TypeAheadFormField( textFieldConfiguration: TextFieldConfiguration( controller: this._ingredientController, - decoration: InputDecoration( - labelText: AppLocalizations.of(context).ingredient), + decoration: InputDecoration(labelText: AppLocalizations.of(context).ingredient), ), suggestionsCallback: (pattern) async { - return await Provider.of(context, - listen: false) + return await Provider.of(context, listen: false) .searchIngredient( pattern, Localizations.localeOf(context).languageCode, @@ -160,8 +154,7 @@ class MealItemForm extends StatelessWidget { }, ), TextFormField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context).weight), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weight), controller: _amountController, keyboardType: TextInputType.number, onFieldSubmitted: (_) {}, @@ -222,8 +215,7 @@ class PlanForm extends StatelessWidget { // Description TextFormField( key: Key('field-description'), - decoration: InputDecoration( - labelText: AppLocalizations.of(context).description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), controller: _descriptionController, onFieldSubmitted: (_) {}, onSaved: (newValue) { @@ -244,13 +236,10 @@ class PlanForm extends StatelessWidget { // Save to DB try { if (_plan.id != null) { - await Provider.of(context, - listen: false) - .editPlan(_plan); + await Provider.of(context, listen: false).editPlan(_plan); Navigator.of(context).pop(); } else { - _plan = await Provider.of(context, - listen: false) + _plan = await Provider.of(context, listen: false) .addPlan(_plan); Navigator.of(context).pushReplacementNamed( NutritionalPlanScreen.routeName, diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index fe766e29..54335df8 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -54,8 +54,7 @@ class _MealWidgetState extends State { child: Card( child: Column( children: [ - DismissibleMealHeader(_expanded, _toggleExpanded, - meal: widget._meal), + DismissibleMealHeader(_expanded, _toggleExpanded, meal: widget._meal), if (_expanded) Row( mainAxisSize: MainAxisSize.max, @@ -64,8 +63,7 @@ class _MealWidgetState extends State { IconButton( onPressed: () { // Delete the meal - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .deleteMeal(widget._meal); // and inform the user @@ -90,8 +88,7 @@ class _MealWidgetState extends State { icon: const Icon(Icons.history_edu), color: Colors.white, onPressed: () { - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .logMealToDiary(widget._meal); ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -152,9 +149,7 @@ class _MealWidgetState extends State { ], ), ), - ...widget._meal.mealItems - .map((item) => MealItemWidget(item, _expanded)) - .toList(), + ...widget._meal.mealItems.map((item) => MealItemWidget(item, _expanded)).toList(), OutlinedButton( child: Text(AppLocalizations.of(context).addIngredient), onPressed: () { @@ -215,8 +210,7 @@ class MealItemWidget extends StatelessWidget { iconSize: ICON_SIZE_SMALL, onPressed: () { // Delete the meal item - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .deleteMealItem(_item); // and inform the user @@ -297,8 +291,7 @@ class DismissibleMealHeader extends StatelessWidget { ), IconButton( visualDensity: VisualDensity.compact, - icon: - _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more), + icon: _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more), onPressed: () { _toggle(); }, @@ -327,8 +320,7 @@ class DismissibleMealHeader extends StatelessWidget { confirmDismiss: (direction) async { // Delete if (direction == DismissDirection.startToEnd) { - Provider.of(context, listen: false) - .logMealToDiary(_meal); + Provider.of(context, listen: false).logMealToDiary(_meal); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( diff --git a/lib/widgets/nutrition/nutritional_plan_detail.dart b/lib/widgets/nutrition/nutritional_plan_detail.dart index 79b7485a..b0c68872 100644 --- a/lib/widgets/nutrition/nutritional_plan_detail.dart +++ b/lib/widgets/nutrition/nutritional_plan_detail.dart @@ -89,8 +89,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget { Text(nutritionalValues.energy.toStringAsFixed(0)), Text(nutritionalValues.protein.toStringAsFixed(0)), Text(nutritionalValues.carbohydrates.toStringAsFixed(0)), - Text(nutritionalValues.carbohydratesSugar - .toStringAsFixed(0)), + Text(nutritionalValues.carbohydratesSugar.toStringAsFixed(0)), Text(nutritionalValues.fat.toStringAsFixed(0)), Text(nutritionalValues.fatSaturated.toStringAsFixed(0)), Text(nutritionalValues.fibres.toStringAsFixed(0)), @@ -122,8 +121,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget { Container( padding: EdgeInsets.all(15), height: 220, - child: - NutritionalDiaryChartWidget(nutritionalPlan: _nutritionalPlan), + child: NutritionalDiaryChartWidget(nutritionalPlan: _nutritionalPlan), ), Container( height: 200, @@ -181,8 +179,7 @@ class NutritionDiaryEntry extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(date), + DateFormat.yMd(Localizations.localeOf(context).languageCode).format(date), style: TextStyle(fontWeight: FontWeight.bold), ), Text(values.energy.toStringAsFixed(0)), diff --git a/lib/widgets/nutrition/nutritional_plans_list.dart b/lib/widgets/nutrition/nutritional_plans_list.dart index 09ba9ece..5cf6c603 100644 --- a/lib/widgets/nutrition/nutritional_plans_list.dart +++ b/lib/widgets/nutrition/nutritional_plans_list.dart @@ -42,13 +42,11 @@ class NutritionalPlansList extends StatelessWidget { builder: (BuildContext contextDialog) { return AlertDialog( content: Text( - AppLocalizations.of(context) - .confirmDelete(currentPlan.description), + AppLocalizations.of(context).confirmDelete(currentPlan.description), ), actions: [ TextButton( - child: Text(MaterialLocalizations.of(context) - .cancelButtonLabel), + child: Text(MaterialLocalizations.of(context).cancelButtonLabel), onPressed: () => Navigator.of(contextDialog).pop(), ), TextButton( @@ -67,8 +65,7 @@ class NutritionalPlansList extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context) - .successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), diff --git a/lib/widgets/weight/charts.dart b/lib/widgets/weight/charts.dart index 2fd1d313..4ccfa9d9 100644 --- a/lib/widgets/weight/charts.dart +++ b/lib/widgets/weight/charts.dart @@ -43,8 +43,7 @@ class WeightChartWidget extends StatelessWidget { ], defaultRenderer: new charts.LineRendererConfig(includePoints: true), primaryMeasureAxis: new charts.NumericAxisSpec( - tickProviderSpec: - new charts.BasicNumericTickProviderSpec(zeroBound: false), + tickProviderSpec: new charts.BasicNumericTickProviderSpec(zeroBound: false), ), ); } diff --git a/lib/widgets/weight/entries_list.dart b/lib/widgets/weight/entries_list.dart index 2830d52f..48f07554 100644 --- a/lib/widgets/weight/entries_list.dart +++ b/lib/widgets/weight/entries_list.dart @@ -28,8 +28,7 @@ import 'package:wger/widgets/weight/forms.dart'; class WeightEntriesList extends StatelessWidget { @override Widget build(BuildContext context) { - final _weightProvider = - Provider.of(context, listen: false); + final _weightProvider = Provider.of(context, listen: false); return Column( children: [ @@ -107,8 +106,7 @@ class WeightEntriesList extends StatelessWidget { child: ListTile( title: Text('${currentEntry.weight} kg'), subtitle: Text( - DateFormat.yMd( - Localizations.localeOf(context).languageCode) + DateFormat.yMd(Localizations.localeOf(context).languageCode) .format(currentEntry.date), ), ), diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart index f8515c95..7a476208 100644 --- a/lib/widgets/weight/forms.dart +++ b/lib/widgets/weight/forms.dart @@ -35,8 +35,7 @@ class WeightForm extends StatelessWidget { WeightForm([WeightEntry? weightEntry]) { this._weightEntry = weightEntry ?? WeightEntry(date: DateTime.now()); - weightController.text = - _weightEntry.id == null ? '' : _weightEntry.weight.toString(); + weightController.text = _weightEntry.id == null ? '' : _weightEntry.weight.toString(); dateController.text = toDate(_weightEntry.date)!; } @@ -48,8 +47,7 @@ class WeightForm extends StatelessWidget { children: [ // Weight date TextFormField( - decoration: - InputDecoration(labelText: AppLocalizations.of(context).date), + decoration: InputDecoration(labelText: AppLocalizations.of(context).date), controller: dateController, onTap: () async { // Stop keyboard from appearing @@ -68,8 +66,7 @@ class WeightForm extends StatelessWidget { } // if the date is known, don't allow it - return Provider.of(context, listen: false) - .findByDate(day) == + return Provider.of(context, listen: false).findByDate(day) == null ? true : false; @@ -85,8 +82,7 @@ class WeightForm extends StatelessWidget { // Weight TextFormField( - decoration: - InputDecoration(labelText: AppLocalizations.of(context).weight), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weight), controller: weightController, keyboardType: TextInputType.number, onSaved: (newValue) { @@ -117,11 +113,9 @@ class WeightForm extends StatelessWidget { // Save the entry on the server try { _weightEntry.id == null - ? await Provider.of(context, - listen: false) + ? await Provider.of(context, listen: false) .addEntry(_weightEntry) - : await Provider.of(context, - listen: false) + : await Provider.of(context, listen: false) .editEntry(_weightEntry); } on WgerHttpException catch (error) { showHttpExceptionErrorDialog(error, context); diff --git a/lib/widgets/workouts/charts.dart b/lib/widgets/workouts/charts.dart index 1b5ab338..86823ed1 100644 --- a/lib/widgets/workouts/charts.dart +++ b/lib/widgets/workouts/charts.dart @@ -56,8 +56,7 @@ class LogChartWidget extends StatelessWidget { }), ], primaryMeasureAxis: new charts.NumericAxisSpec( - tickProviderSpec: - new charts.BasicNumericTickProviderSpec(zeroBound: false), + tickProviderSpec: new charts.BasicNumericTickProviderSpec(zeroBound: false), ), behaviors: [ new charts.SeriesLegend( diff --git a/lib/widgets/workouts/day.dart b/lib/widgets/workouts/day.dart index 6a47c81f..f8a25a9d 100644 --- a/lib/widgets/workouts/day.dart +++ b/lib/widgets/workouts/day.dart @@ -61,8 +61,7 @@ class SettingWidget extends StatelessWidget { content: ExerciseDetail(setting.exerciseObj), actions: [ TextButton( - child: Text( - MaterialLocalizations.of(context).closeButtonLabel), + child: Text(MaterialLocalizations.of(context).closeButtonLabel), onPressed: () { Navigator.of(context).pop(); }, @@ -129,8 +128,7 @@ class _WorkoutDayWidgetState extends State { icon: Icon(Icons.delete), iconSize: ICON_SIZE_SMALL, onPressed: () { - Provider.of(context, listen: false) - .deleteSet(set); + Provider.of(context, listen: false).deleteSet(set); }, ), ], @@ -157,8 +155,7 @@ class _WorkoutDayWidgetState extends State { children: [ IconButton( onPressed: () { - Provider.of(context, listen: false) - .deleteDay( + Provider.of(context, listen: false).deleteDay( widget._day, ); }, @@ -189,8 +186,7 @@ class _WorkoutDayWidgetState extends State { arguments: FormScreenArguments( AppLocalizations.of(context).edit, DayFormWidget( - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .findById(widget._day.workoutId), widget._day), hasListView: true, @@ -263,14 +259,12 @@ class DayHeaderDismissible extends StatelessWidget { style: Theme.of(context).textTheme.headline5, overflow: TextOverflow.ellipsis, ), - Text(_day.getDaysTextTranslated( - Localizations.localeOf(context).languageCode)), + Text(_day.getDaysTextTranslated(Localizations.localeOf(context).languageCode)), ], ), ), IconButton( - icon: - _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more), + icon: _expanded ? Icon(Icons.unfold_less) : Icon(Icons.unfold_more), onPressed: () { _toggle(); }, @@ -299,8 +293,7 @@ class DayHeaderDismissible extends StatelessWidget { confirmDismiss: (direction) async { // Delete day if (direction == DismissDirection.startToEnd) { - Navigator.of(context) - .pushNamed(GymModeScreen.routeName, arguments: _day); + Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: _day); } return false; }, diff --git a/lib/widgets/workouts/forms.dart b/lib/widgets/workouts/forms.dart index 2672ba40..b6baff1f 100644 --- a/lib/widgets/workouts/forms.dart +++ b/lib/widgets/workouts/forms.dart @@ -41,8 +41,7 @@ class WorkoutForm extends StatelessWidget { WorkoutForm(this._plan); final TextEditingController workoutNameController = TextEditingController(); - final TextEditingController workoutDescriptionController = - TextEditingController(); + final TextEditingController workoutDescriptionController = TextEditingController(); @override Widget build(BuildContext context) { @@ -57,17 +56,13 @@ class WorkoutForm extends StatelessWidget { children: [ TextFormField( key: Key('field-name'), - decoration: - InputDecoration(labelText: AppLocalizations.of(context).name), + decoration: InputDecoration(labelText: AppLocalizations.of(context).name), controller: workoutNameController, validator: (value) { const minLength = 5; const maxLength = 100; - if (value!.isEmpty || - value.length < minLength || - value.length > maxLength) { - return AppLocalizations.of(context) - .enterCharacters(minLength, maxLength); + if (value!.isEmpty || value.length < minLength || value.length > maxLength) { + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } return null; }, @@ -78,8 +73,7 @@ class WorkoutForm extends StatelessWidget { ), TextFormField( key: Key('field-description'), - decoration: InputDecoration( - labelText: AppLocalizations.of(context).description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), minLines: 3, maxLines: 10, controller: workoutDescriptionController, @@ -87,8 +81,7 @@ class WorkoutForm extends StatelessWidget { const minLength = 0; const maxLength = 1000; if (value!.length > maxLength) { - return AppLocalizations.of(context) - .enterCharacters(minLength, maxLength); + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } return null; }, @@ -110,12 +103,10 @@ class WorkoutForm extends StatelessWidget { // Save to DB if (_plan.id != null) { - await Provider.of(context, listen: false) - .editWorkout(_plan); + await Provider.of(context, listen: false).editWorkout(_plan); Navigator.of(context).pop(); } else { - _plan = await Provider.of(context, - listen: false) + _plan = await Provider.of(context, listen: false) .addWorkout(_plan); Navigator.of(context).pushReplacementNamed( WorkoutPlanScreen.routeName, @@ -203,11 +194,8 @@ class _DayFormWidgetState extends State { validator: (value) { const minLength = 5; const maxLength = 100; - if (value!.isEmpty || - value.length < minLength || - value.length > maxLength) { - return AppLocalizations.of(context) - .enterCharacters(minLength, maxLength); + if (value!.isEmpty || value.length < minLength || value.length > maxLength) { + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } if (widget._day.daysOfWeek.length == 0) { @@ -217,9 +205,7 @@ class _DayFormWidgetState extends State { }, ), SizedBox(height: 10), - ...Day.weekdays.keys - .map((dayNr) => DayCheckbox(dayNr, widget._day)) - .toList(), + ...Day.weekdays.keys.map((dayNr) => DayCheckbox(dayNr, widget._day)).toList(), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), child: Text(AppLocalizations.of(context).save), @@ -231,14 +217,12 @@ class _DayFormWidgetState extends State { try { if (widget._day.id == null) { - Provider.of(context, listen: false) - .addDay( + Provider.of(context, listen: false).addDay( widget._day, widget.workout, ); } else { - Provider.of(context, listen: false) - .editDay( + Provider.of(context, listen: false).editDay( widget._day, ); } @@ -316,11 +300,9 @@ class _SetFormWidgetState extends State { setting.order = order; setting.exercise = exercise; setting.weightUnit = - Provider.of(context, listen: false) - .defaultWeightUnit; + Provider.of(context, listen: false).defaultWeightUnit; setting.repetitionUnit = - Provider.of(context, listen: false) - .defaultRepetitionUnit; + Provider.of(context, listen: false).defaultRepetitionUnit; widget._set.settings.add(setting); } @@ -339,8 +321,7 @@ class _SetFormWidgetState extends State { child: Column( //crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context) - .nrOfSets(_currentSetSliderValue.round())), + Text(AppLocalizations.of(context).nrOfSets(_currentSetSliderValue.round())), Slider( value: _currentSetSliderValue, min: 1, @@ -389,18 +370,14 @@ class _SetFormWidgetState extends State { content: Column( mainAxisSize: MainAxisSize.min, children: [ - Text(AppLocalizations.of(context) - .selectExercises), + Text(AppLocalizations.of(context).selectExercises), SizedBox(height: 10), - Text(AppLocalizations.of(context) - .sameRepetitions) + Text(AppLocalizations.of(context).sameRepetitions) ], ), actions: [ TextButton( - child: Text( - MaterialLocalizations.of(context) - .closeButtonLabel), + child: Text(MaterialLocalizations.of(context).closeButtonLabel), onPressed: () { Navigator.of(context).pop(); }, @@ -414,8 +391,7 @@ class _SetFormWidgetState extends State { ), ), suggestionsCallback: (pattern) async { - return await Provider.of(context, - listen: false) + return await Provider.of(context, listen: false) .searchExercise( pattern, Localizations.localeOf(context).languageCode, @@ -424,14 +400,12 @@ class _SetFormWidgetState extends State { itemBuilder: (context, suggestion) { final result = suggestion! as Map; - final exercise = - Provider.of(context, listen: false) - .findById(result['data']['id']); + final exercise = Provider.of(context, listen: false) + .findById(result['data']['id']); return ListTile( leading: Container( width: 45, - child: - ExerciseImageWidget(image: exercise.getMainImage), + child: ExerciseImageWidget(image: exercise.getMainImage), ), title: Text(exercise.name), subtitle: Text( @@ -443,9 +417,8 @@ class _SetFormWidgetState extends State { }, onSuggestionSelected: (suggestion) { final result = suggestion! as Map; - final exercise = - Provider.of(context, listen: false) - .findById(result['data']['id']); + final exercise = Provider.of(context, listen: false) + .findById(result['data']['id']); addExercise(exercise); this._exercisesController.text = ''; }, @@ -460,8 +433,7 @@ class _SetFormWidgetState extends State { .where((s) => s.weight == null && s.reps == null) .length == widget._set.settings.length) { - return AppLocalizations.of(context) - .enterRepetitionsOrWeight; + return AppLocalizations.of(context).enterRepetitionsOrWeight; } return null; }, @@ -469,9 +441,8 @@ class _SetFormWidgetState extends State { ), SizedBox(height: 10), ...widget._set.exercisesObj.map((exercise) { - final settings = widget._set.settings - .where((e) => e.exerciseObj.id == exercise.id) - .toList(); + final settings = + widget._set.settings.where((e) => e.exerciseObj.id == exercise.id).toList(); return ExerciseSetting( exercise, @@ -491,25 +462,22 @@ class _SetFormWidgetState extends State { } _formKey.currentState!.save(); - final workoutProvider = Provider.of( - context, - listen: false); + final workoutProvider = + Provider.of(context, listen: false); // Save set Set setDb = await workoutProvider.addSet(widget._set); widget._set.id = setDb.id; // Remove unused settings - widget._set.settings - .removeWhere((s) => s.weight == null && s.reps == null); + widget._set.settings.removeWhere((s) => s.weight == null && s.reps == null); // Save remaining settings for (var setting in widget._set.settings) { setting.setId = setDb.id!; setting.comment = ''; - Setting settingDb = - await workoutProvider.addSetting(setting); + Setting settingDb = await workoutProvider.addSetting(setting); setting.id = settingDb.id; } @@ -585,8 +553,7 @@ class ExerciseSetting extends StatelessWidget { SizedBox(width: 4), Flexible( flex: 3, - child: - WeightUnitInputWidget(setting, key: Key(i.toString())), + child: WeightUnitInputWidget(setting, key: Key(i.toString())), ), ], ), @@ -833,8 +800,7 @@ class _WeightUnitInputWidgetState extends State { return DropdownButtonFormField( value: selectedWeightUnit, - decoration: - InputDecoration(labelText: AppLocalizations.of(context).weightUnit), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weightUnit), onChanged: (WeightUnit? newValue) { setState(() { selectedWeightUnit = newValue!; @@ -861,8 +827,7 @@ class RepetitionUnitInputWidget extends StatefulWidget { RepetitionUnitInputWidget(this._setting); @override - _RepetitionUnitInputWidgetState createState() => - _RepetitionUnitInputWidgetState(); + _RepetitionUnitInputWidgetState createState() => _RepetitionUnitInputWidgetState(); } class _RepetitionUnitInputWidgetState extends State { @@ -872,8 +837,7 @@ class _RepetitionUnitInputWidgetState extends State { return DropdownButtonFormField( value: selectedWeightUnit, - decoration: InputDecoration( - labelText: AppLocalizations.of(context).repetitionUnit), + decoration: InputDecoration(labelText: AppLocalizations.of(context).repetitionUnit), isDense: true, onChanged: (RepetitionUnit? newValue) { setState(() { diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index 061f10f3..935596dc 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -87,8 +87,8 @@ class _GymModeState extends State { for (var set in widget._workoutDay.sets) { var firstPage = true; for (var setting in set.settingsComputed) { - final exercise = Provider.of(context, listen: false) - .findById(setting.exerciseId); + final exercise = + Provider.of(context, listen: false).findById(setting.exerciseId); if (firstPage) { _exercisePages[exercise.name] = currentPage; @@ -107,10 +107,8 @@ class _GymModeState extends State { // Returns the list of exercise overview, sets and pause pages List getContent() { - final exerciseProvider = - Provider.of(context, listen: false); - final workoutProvider = - Provider.of(context, listen: false); + final exerciseProvider = Provider.of(context, listen: false); + final workoutProvider = Provider.of(context, listen: false); var currentElement = 1; List out = []; @@ -200,10 +198,7 @@ class StartPage extends StatelessWidget { s.exerciseObj.name, style: Theme.of(context).textTheme.headline6, ), - ...set - .getSmartRepr(s.exerciseObj) - .map((e) => Text(e)) - .toList(), + ...set.getSmartRepr(s.exerciseObj).map((e) => Text(e)).toList(), SizedBox(height: 15), ], ); @@ -218,8 +213,7 @@ class StartPage extends StatelessWidget { ElevatedButton( child: Text(AppLocalizations.of(context).start), onPressed: () { - _controller.nextPage( - duration: Duration(milliseconds: 200), curve: Curves.bounceIn); + _controller.nextPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn); }, ), NavigationFooter( @@ -347,8 +341,7 @@ class _LogPageState extends State { ), onPressed: () { try { - double newValue = - double.parse(_weightController.text) - (2 * minPlateWeight); + double newValue = double.parse(_weightController.text) - (2 * minPlateWeight); if (newValue > 0) { setState(() { widget._log.weight = newValue; @@ -396,8 +389,7 @@ class _LogPageState extends State { ), onPressed: () { try { - double newValue = - double.parse(_weightController.text) + (2 * minPlateWeight); + double newValue = double.parse(_weightController.text) + (2 * minPlateWeight); setState(() { widget._log.weight = newValue; _weightController.text = newValue.toString(); @@ -468,8 +460,7 @@ class _LogPageState extends State { // Save the entry on the server try { - await Provider.of(context, listen: false) - .addLog(widget._log); + await Provider.of(context, listen: false).addLog(widget._log); ScaffoldMessenger.of(context).showSnackBar( SnackBar( duration: Duration(seconds: 2), // default is 4 @@ -503,14 +494,11 @@ class _LogPageState extends State { style: Theme.of(context).textTheme.headline6, textAlign: TextAlign.center, ), - ...widget._workoutPlan - .filterLogsByExercise(widget._exercise, unique: true) - .map((log) { + ...widget._workoutPlan.filterLogsByExercise(widget._exercise, unique: true).map((log) { return ListTile( title: Text(log.singleLogRepTextNoNl), - subtitle: Text( - DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(log.date)), + subtitle: + Text(DateFormat.yMd(Localizations.localeOf(context).languageCode).format(log.date)), trailing: Icon(Icons.copy), onTap: () { setState(() { @@ -563,8 +551,7 @@ class _LogPageState extends State { shape: BoxShape.circle, ), child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 3), + padding: const EdgeInsets.symmetric(horizontal: 3), child: SizedBox( height: 35, width: 35, @@ -572,8 +559,7 @@ class _LogPageState extends State { alignment: Alignment.center, child: Text( key.toString(), - style: TextStyle( - fontWeight: FontWeight.bold), + style: TextStyle(fontWeight: FontWeight.bold), ), ), ), @@ -586,8 +572,7 @@ class _LogPageState extends State { .toList() ], ) - : MutedText( - AppLocalizations.of(context).plateCalculatorNotDivisible), + : MutedText(AppLocalizations.of(context).plateCalculatorNotDivisible), ), SizedBox(height: 3), ], @@ -612,16 +597,11 @@ class _LogPageState extends State { ), SizedBox(height: 10), Expanded( - child: (widget._workoutPlan - .filterLogsByExercise(widget._exercise) - .length > - 0) + child: (widget._workoutPlan.filterLogsByExercise(widget._exercise).length > 0) ? getPastLogs() : Container()), // Only show calculator for barbell - if (widget._log.exerciseObj.equipment - .map((e) => e.id) - .contains(ID_EQUIPMENT_BARBELL)) + if (widget._log.exerciseObj.equipment.map((e) => e.id).contains(ID_EQUIPMENT_BARBELL)) getPlates(), Padding( padding: const EdgeInsets.symmetric(horizontal: 15), @@ -682,9 +662,7 @@ class ExerciseOverview extends StatelessWidget { child: ListView( scrollDirection: Axis.horizontal, children: [ - ..._exercise.images - .map((e) => ExerciseImageWidget(image: e)) - .toList(), + ..._exercise.images.map((e) => ExerciseImageWidget(image: e)).toList(), ], ), ), @@ -810,8 +788,7 @@ class _SessionPageState extends State { onFieldSubmitted: (_) {}, onTap: () async { // Stop keyboard from appearing - FocusScope.of(context) - .requestFocus(new FocusNode()); + FocusScope.of(context).requestFocus(new FocusNode()); // Open time picker var pickedTime = await showTimePicker( @@ -820,21 +797,17 @@ class _SessionPageState extends State { ); if (pickedTime != null) { - timeStartController.text = - timeToString(pickedTime)!; + timeStartController.text = timeToString(pickedTime)!; } }, onSaved: (newValue) { _session.timeStart = stringToTime(newValue); }, validator: (_) { - TimeOfDay startTime = - stringToTime(timeStartController.text); - TimeOfDay endTime = - stringToTime(timeEndController.text); + TimeOfDay startTime = stringToTime(timeStartController.text); + TimeOfDay endTime = stringToTime(timeEndController.text); if (startTime.isAfter(endTime)) { - return AppLocalizations.of(context) - .timeStartAhead; + return AppLocalizations.of(context).timeStartAhead; } return null; }), @@ -842,8 +815,8 @@ class _SessionPageState extends State { SizedBox(width: 10), Flexible( child: TextFormField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context).timeEnd), + decoration: + InputDecoration(labelText: AppLocalizations.of(context).timeEnd), controller: timeEndController, onFieldSubmitted: (_) {}, onTap: () async { @@ -877,8 +850,7 @@ class _SessionPageState extends State { // Save the entry on the server try { - await Provider.of(context, - listen: false) + await Provider.of(context, listen: false) .addSession(_session); Navigator.of(context).pop(); } on WgerHttpException catch (error) { @@ -971,10 +943,7 @@ class _TimerWidgetState extends State { child: Center( child: Text( DateFormat('m:ss').format(today.add(Duration(seconds: _seconds))), - style: Theme.of(context) - .textTheme - .headline1! - .copyWith(color: wgerPrimaryColor), + style: Theme.of(context).textTheme.headline1!.copyWith(color: wgerPrimaryColor), ), ), ), diff --git a/lib/widgets/workouts/log.dart b/lib/widgets/workouts/log.dart index 9a9d6acb..d6ad7617 100644 --- a/lib/widgets/workouts/log.dart +++ b/lib/widgets/workouts/log.dart @@ -34,8 +34,7 @@ class ExerciseLogChart extends StatelessWidget { @override Widget build(BuildContext context) { - final _workoutPlansData = - Provider.of(context, listen: false); + final _workoutPlansData = Provider.of(context, listen: false); final _workout = _workoutPlansData.currentPlan; Future> _getChartEntries(BuildContext context) async { @@ -44,8 +43,7 @@ class ExerciseLogChart extends StatelessWidget { return FutureBuilder( future: _getChartEntries(context), - builder: (context, AsyncSnapshot> snapshot) => - Container( + builder: (context, AsyncSnapshot> snapshot) => Container( height: 150, child: snapshot.connectionState == ConnectionState.waiting ? Center(child: CircularProgressIndicator()) @@ -68,8 +66,7 @@ class DayLogWidget extends StatelessWidget { child: Column( children: [ Text( - DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(_date), + DateFormat.yMd(Localizations.localeOf(context).languageCode).format(_date), style: Theme.of(context).textTheme.headline5, ), if (_session != null) Text('Session data here'), @@ -80,9 +77,7 @@ class DayLogWidget extends StatelessWidget { exercise.name, style: Theme.of(context).textTheme.headline6, ), - ..._exerciseData[exercise]! - .map((log) => Text(log.singleLogRepTextNoNl)) - .toList(), + ..._exerciseData[exercise]!.map((log) => Text(log.singleLogRepTextNoNl)).toList(), ExerciseLogChart(exercise, _date), SizedBox(height: 30), ], diff --git a/lib/widgets/workouts/workout_plan_detail.dart b/lib/widgets/workouts/workout_plan_detail.dart index 4382dacb..a1958503 100644 --- a/lib/widgets/workouts/workout_plan_detail.dart +++ b/lib/widgets/workouts/workout_plan_detail.dart @@ -57,9 +57,7 @@ class _WorkoutPlanDetailState extends State { padding: const EdgeInsets.all(15), child: Text(widget._workoutPlan.description), ), - ...widget._workoutPlan.days - .map((workoutDay) => WorkoutDayWidget(workoutDay)) - .toList(), + ...widget._workoutPlan.days.map((workoutDay) => WorkoutDayWidget(workoutDay)).toList(), Column( children: [ ElevatedButton( diff --git a/lib/widgets/workouts/workout_plans_list.dart b/lib/widgets/workouts/workout_plans_list.dart index d67e4b3d..bf3059a6 100644 --- a/lib/widgets/workouts/workout_plans_list.dart +++ b/lib/widgets/workouts/workout_plans_list.dart @@ -44,13 +44,11 @@ class WorkoutPlansList extends StatelessWidget { builder: (BuildContext contextDialog) { return AlertDialog( content: Text( - AppLocalizations.of(context) - .confirmDelete(currentWorkout.name), + AppLocalizations.of(context).confirmDelete(currentWorkout.name), ), actions: [ TextButton( - child: Text(MaterialLocalizations.of(context) - .cancelButtonLabel), + child: Text(MaterialLocalizations.of(context).cancelButtonLabel), onPressed: () => Navigator.of(contextDialog).pop(), ), TextButton( @@ -60,8 +58,7 @@ class WorkoutPlansList extends StatelessWidget { ), onPressed: () { // Confirmed, delete the workout - Provider.of(context, - listen: false) + Provider.of(context, listen: false) .deleteWorkout(currentWorkout.id!); // Close the popup @@ -71,8 +68,7 @@ class WorkoutPlansList extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context) - .successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), @@ -103,8 +99,8 @@ class WorkoutPlansList extends StatelessWidget { onTap: () { _workoutProvider.setCurrentPlan(currentWorkout.id!); - Navigator.of(context).pushNamed(WorkoutPlanScreen.routeName, - arguments: currentWorkout); + Navigator.of(context) + .pushNamed(WorkoutPlanScreen.routeName, arguments: currentWorkout); }, title: Text(currentWorkout.name), subtitle: Text( diff --git a/test/auth_screen_test.dart b/test/auth_screen_test.dart index 9e7deafa..0320bbab 100644 --- a/test/auth_screen_test.dart +++ b/test/auth_screen_test.dart @@ -24,8 +24,7 @@ import 'package:wger/providers/auth.dart'; import 'package:wger/screens/auth_screen.dart'; void main() { - testWidgets('Test the widgets on the auth screen, login mode', - (WidgetTester tester) async { + testWidgets('Test the widgets on the auth screen, login mode', (WidgetTester tester) async { // Wrap screen in material app so that the media query gets a context await tester.pumpWidget( MultiProvider( @@ -81,8 +80,7 @@ void main() { // either the provider wasn't found or, if the call was removed, the // localization data could not be loaded... - testWidgets('Test the widgets on the auth screen, registration', - (WidgetTester tester) async { + testWidgets('Test the widgets on the auth screen, registration', (WidgetTester tester) async { // Wrap screen in material app so that the media query gets a context await tester.pumpWidget(MaterialApp(home: AuthScreen())); await tester.tap(find.byKey(Key('toggleActionButton'))); diff --git a/test/base_provider_test.dart b/test/base_provider_test.dart index 98bc8ebd..bfec04ae 100644 --- a/test/base_provider_test.dart +++ b/test/base_provider_test.dart @@ -46,20 +46,16 @@ void main() { provider.makeUrl('endpoint', query: {'a': '2', 'b': 'c'}), ); expect( - Uri.https( - 'localhost', '/api/v2/endpoint/log_data/', {'a': '2', 'b': 'c'}), - provider.makeUrl('endpoint', - objectMethod: 'log_data', query: {'a': '2', 'b': 'c'}), + Uri.https('localhost', '/api/v2/endpoint/log_data/', {'a': '2', 'b': 'c'}), + provider.makeUrl('endpoint', objectMethod: 'log_data', query: {'a': '2', 'b': 'c'}), ); expect( Uri.https('localhost', '/api/v2/endpoint/42/', {'a': '2', 'b': 'c'}), provider.makeUrl('endpoint', id: 42, query: {'a': '2', 'b': 'c'}), ); expect( - Uri.https( - 'localhost', '/api/v2/endpoint/42/log_data/', {'a': '2', 'b': 'c'}), - provider.makeUrl('endpoint', - id: 42, objectMethod: 'log_data', query: {'a': '2', 'b': 'c'}), + Uri.https('localhost', '/api/v2/endpoint/42/log_data/', {'a': '2', 'b': 'c'}), + provider.makeUrl('endpoint', id: 42, objectMethod: 'log_data', query: {'a': '2', 'b': 'c'}), ); }); }); diff --git a/test/base_provider_test.mocks.dart b/test/base_provider_test.mocks.dart index e9d4fa14..47942b95 100644 --- a/test/base_provider_test.mocks.dart +++ b/test/base_provider_test.mocks.dart @@ -36,71 +36,49 @@ class MockClient extends _i1.Mock implements _i5.Client { @override _i6.Future<_i2.Response> head(Uri? url, {Map? headers}) => (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future<_i2.Response> get(Uri? url, {Map? headers}) => (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future<_i2.Response> post(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + {Map? headers, Object? body, _i7.Encoding? encoding}) => (super.noSuchMethod( - Invocation.method(#post, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + Invocation.method(#post, [url], {#headers: headers, #body: body, #encoding: encoding}), + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future<_i2.Response> put(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + {Map? headers, Object? body, _i7.Encoding? encoding}) => (super.noSuchMethod( - Invocation.method(#put, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + Invocation.method(#put, [url], {#headers: headers, #body: body, #encoding: encoding}), + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future<_i2.Response> patch(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + {Map? headers, Object? body, _i7.Encoding? encoding}) => (super.noSuchMethod( - Invocation.method(#patch, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + Invocation.method(#patch, [url], {#headers: headers, #body: body, #encoding: encoding}), + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future<_i2.Response> delete(Uri? url, - {Map? headers, - Object? body, - _i7.Encoding? encoding}) => + {Map? headers, Object? body, _i7.Encoding? encoding}) => (super.noSuchMethod( - Invocation.method(#delete, [url], - {#headers: headers, #body: body, #encoding: encoding}), - returnValue: Future<_i2.Response>.value(_FakeResponse())) - as _i6.Future<_i2.Response>); + Invocation.method(#delete, [url], {#headers: headers, #body: body, #encoding: encoding}), + returnValue: Future<_i2.Response>.value(_FakeResponse())) as _i6.Future<_i2.Response>); @override _i6.Future read(Uri? url, {Map? headers}) => (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}), returnValue: Future.value('')) as _i6.Future); @override - _i6.Future<_i3.Uint8List> readBytes(Uri? url, - {Map? headers}) => - (super.noSuchMethod( - Invocation.method(#readBytes, [url], {#headers: headers}), - returnValue: Future<_i3.Uint8List>.value(_FakeUint8List())) - as _i6.Future<_i3.Uint8List>); + _i6.Future<_i3.Uint8List> readBytes(Uri? url, {Map? headers}) => + (super.noSuchMethod(Invocation.method(#readBytes, [url], {#headers: headers}), + returnValue: Future<_i3.Uint8List>.value(_FakeUint8List())) as _i6.Future<_i3.Uint8List>); @override _i6.Future<_i4.StreamedResponse> send(_i8.BaseRequest? request) => (super.noSuchMethod(Invocation.method(#send, [request]), - returnValue: - Future<_i4.StreamedResponse>.value(_FakeStreamedResponse())) + returnValue: Future<_i4.StreamedResponse>.value(_FakeStreamedResponse())) as _i6.Future<_i4.StreamedResponse>); @override - void close() => super.noSuchMethod(Invocation.method(#close, []), - returnValueForMissingStub: null); + void close() => + super.noSuchMethod(Invocation.method(#close, []), returnValueForMissingStub: null); } diff --git a/test/exercises_detail_widget_test.dart b/test/exercises_detail_widget_test.dart index 2bba4a8e..e62e13ce 100644 --- a/test/exercises_detail_widget_test.dart +++ b/test/exercises_detail_widget_test.dart @@ -54,8 +54,7 @@ main() { ); } - testWidgets('Test the widgets on the SetFormWidget', - (WidgetTester tester) async { + testWidgets('Test the widgets on the SetFormWidget', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.pumpAndSettle(); @@ -66,8 +65,7 @@ main() { expect(find.text('Bench\nDumbbell'), findsOneWidget, reason: 'Equipment'); expect(find.text('Muscles'), findsOneWidget); - expect(find.text('Flutterus maximus\nBiceps'), findsOneWidget, - reason: 'Muscles'); + expect(find.text('Flutterus maximus\nBiceps'), findsOneWidget, reason: 'Muscles'); expect(find.text('Secondary muscles'), findsOneWidget); expect(find.text('Booty'), findsOneWidget, reason: 'Secondary muscles'); diff --git a/test/gallery_form_test.dart b/test/gallery_form_test.dart index e4f48942..a76cc6de 100644 --- a/test/gallery_form_test.dart +++ b/test/gallery_form_test.dart @@ -52,14 +52,11 @@ void main() { ); } - testWidgets('Test opening the form for an existing image', - (WidgetTester tester) async { - await mockNetworkImagesFor( - () => tester.pumpWidget(createScreen(useImage: true))); + testWidgets('Test opening the form for an existing image', (WidgetTester tester) async { + await mockNetworkImagesFor(() => tester.pumpWidget(createScreen(useImage: true))); await tester.pumpAndSettle(); - expect(find.byType(TextFormField), - findsNWidgets(2)); // four in the overview, one in the popup + expect(find.byType(TextFormField), findsNWidgets(2)); // four in the overview, one in the popup expect(find.text('A very cool image from the gym'), findsOneWidget); expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget); @@ -70,10 +67,8 @@ void main() { verify(mockGalleryProvider.editImage(any, any)); }); - testWidgets('Test opening the form for a new image', - (WidgetTester tester) async { - await mockNetworkImagesFor( - () => tester.pumpWidget(createScreen(useImage: false))); + testWidgets('Test opening the form for a new image', (WidgetTester tester) async { + await mockNetworkImagesFor(() => tester.pumpWidget(createScreen(useImage: false))); await tester.pumpAndSettle(); expect(find.text('Please select an image'), findsOneWidget); diff --git a/test/gallery_screen_test.dart b/test/gallery_screen_test.dart index b3b6ea0f..4538964e 100644 --- a/test/gallery_screen_test.dart +++ b/test/gallery_screen_test.dart @@ -54,15 +54,13 @@ void main() { ); } - testWidgets('Test the widgets on the gallery screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the gallery screen', (WidgetTester tester) async { await mockNetworkImagesFor(() => tester.pumpWidget(createScreen())); expect(find.byType(GestureDetector), findsNWidgets(4)); }); - testWidgets('Test opening the form for an existing image', - (WidgetTester tester) async { + testWidgets('Test opening the form for an existing image', (WidgetTester tester) async { await mockNetworkImagesFor(() => tester.pumpWidget(createScreen())); await tester.tap(find.byKey(Key('image-1'))); @@ -70,8 +68,7 @@ void main() { // Detail dialog opens expect(find.byKey(Key('image-1-detail')), findsOneWidget); - expect(find.byType(Image), - findsNWidgets(5)); // four in the overview, one in the popup + expect(find.byType(Image), findsNWidgets(5)); // four in the overview, one in the popup expect(find.text('A very cool image from the gym'), findsOneWidget); expect(find.byIcon(Icons.edit), findsOneWidget); expect(find.byIcon(Icons.delete), findsOneWidget); @@ -85,8 +82,7 @@ void main() { expect(find.byType(ElevatedButton), findsOneWidget); }); - testWidgets('Tests the localization of dates - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async { await mockNetworkImagesFor(() => tester.pumpWidget(createScreen())); await tester.tap(find.byKey(Key('image-1'))); await tester.pumpAndSettle(); @@ -94,10 +90,8 @@ void main() { expect(find.text('5/30/2021'), findsOneWidget); }); - testWidgets('Tests the localization of dates - DE', - (WidgetTester tester) async { - await mockNetworkImagesFor( - () => tester.pumpWidget(createScreen(locale: 'de'))); + testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async { + await mockNetworkImagesFor(() => tester.pumpWidget(createScreen(locale: 'de'))); await tester.tap(find.byKey(Key('image-1'))); await tester.pumpAndSettle(); diff --git a/test/gallery_screen_test.mocks.dart b/test/gallery_screen_test.mocks.dart index 5c476f8d..e6508662 100644 --- a/test/gallery_screen_test.mocks.dart +++ b/test/gallery_screen_test.mocks.dart @@ -7,8 +7,7 @@ import 'dart:ui' as _i9; import 'package:http/src/client.dart' as _i3; import 'package:http/src/response.dart' as _i4; -import 'package:image_picker_platform_interface/src/types/picked_file/io.dart' - as _i8; +import 'package:image_picker_platform_interface/src/types/picked_file/io.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:wger/models/gallery/image.dart' as _i6; import 'package:wger/providers/auth.dart' as _i2; @@ -38,30 +37,28 @@ class MockGalleryProvider extends _i1.Mock implements _i5.GalleryProvider { } @override - List<_i6.Image> get images => (super.noSuchMethod(Invocation.getter(#images), - returnValue: <_i6.Image>[]) as List<_i6.Image>); + List<_i6.Image> get images => + (super.noSuchMethod(Invocation.getter(#images), returnValue: <_i6.Image>[]) + as List<_i6.Image>); @override set images(List<_i6.Image>? _images) => - super.noSuchMethod(Invocation.setter(#images, _images), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#images, _images), returnValueForMissingStub: null); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) - as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i2.AuthProvider get auth => (super.noSuchMethod(Invocation.getter(#auth), - returnValue: _FakeAuthProvider()) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod(Invocation.getter(#auth), returnValue: _FakeAuthProvider()) + as _i2.AuthProvider); @override set auth(_i2.AuthProvider? _auth) => - super.noSuchMethod(Invocation.setter(#auth, _auth), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#auth, _auth), returnValueForMissingStub: null); @override - _i3.Client get client => (super.noSuchMethod(Invocation.getter(#client), - returnValue: _FakeClient()) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod(Invocation.getter(#client), returnValue: _FakeClient()) as _i3.Client); @override set client(_i3.Client? _client) => - super.noSuchMethod(Invocation.setter(#client, _client), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#client, _client), returnValueForMissingStub: null); @override _i7.Future fetchAndSetGallery() => (super.noSuchMethod(Invocation.method(#fetchAndSetGallery, []), @@ -83,48 +80,41 @@ class MockGalleryProvider extends _i1.Mock implements _i5.GalleryProvider { returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => - super.noSuchMethod(Invocation.method(#addListener, [listener]), - returnValueForMissingStub: null); + void addListener(_i9.VoidCallback? listener) => super + .noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override - void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), - returnValueForMissingStub: null); + void dispose() => + super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); @override void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); @override - Uri makeUrl(String? path, - {int? id, String? objectMethod, Map? query}) => + Uri makeUrl(String? path, {int? id, String? objectMethod, Map? query}) => (super.noSuchMethod( - Invocation.method(#makeUrl, [path], - {#id: id, #objectMethod: objectMethod, #query: query}), + Invocation.method( + #makeUrl, [path], {#id: id, #objectMethod: objectMethod, #query: query}), returnValue: _FakeUri()) as Uri); @override - _i7.Future> fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method(#fetch, [uri]), - returnValue: Future>.value({})) - as _i7.Future>); + _i7.Future> fetch(Uri? uri) => + (super.noSuchMethod(Invocation.method(#fetch, [uri]), + returnValue: Future>.value({})) + as _i7.Future>); @override _i7.Future> post(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#post, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i7.Future>); @override - _i7.Future> patch( - Map? data, Uri? uri) => + _i7.Future> patch(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#patch, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i7.Future>); @override _i7.Future<_i4.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(Invocation.method(#deleteRequest, [url, id]), - returnValue: Future<_i4.Response>.value(_FakeResponse())) - as _i7.Future<_i4.Response>); + returnValue: Future<_i4.Response>.value(_FakeResponse())) as _i7.Future<_i4.Response>); } diff --git a/test/gym_mode_screen_test.dart b/test/gym_mode_screen_test.dart index 567d4002..a4bca19a 100644 --- a/test/gym_mode_screen_test.dart +++ b/test/gym_mode_screen_test.dart @@ -69,8 +69,7 @@ void main() { ); } - testWidgets('Test the widgets on the gym mode screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the gym mode screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); @@ -106,8 +105,7 @@ void main() { expect(find.text('test exercise 1'), findsOneWidget); expect(find.byType(LogPage), findsOneWidget); expect(find.byType(Form), findsOneWidget); - expect(find.byType(ListTile), findsNWidgets(3), - reason: 'Two logs and the switch tile'); + expect(find.byType(ListTile), findsNWidgets(3), reason: 'Two logs and the switch tile'); expect(find.text('10 × 10 kg (1.5 RiR)'), findsOneWidget); expect(find.text('12 × 10 kg (2 RiR)'), findsOneWidget); expect(find.byIcon(Icons.close), findsOneWidget); diff --git a/test/nutritional_meal_form_test.dart b/test/nutritional_meal_form_test.dart index d30fe424..699e0002 100644 --- a/test/nutritional_meal_form_test.dart +++ b/test/nutritional_meal_form_test.dart @@ -94,8 +94,7 @@ void main() { verifyNever(mockNutrition.addMeal(any, any)); }); - testWidgets('Test creating a new nutritional plan', - (WidgetTester tester) async { + testWidgets('Test creating a new nutritional plan', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(meal2)); await tester.pumpAndSettle(); diff --git a/test/nutritional_plan_form_test.dart b/test/nutritional_plan_form_test.dart index b19e42fd..d909c5e6 100644 --- a/test/nutritional_plan_form_test.dart +++ b/test/nutritional_plan_form_test.dart @@ -68,8 +68,7 @@ void main() { ); } - testWidgets('Test the widgets on the nutritional plan form', - (WidgetTester tester) async { + testWidgets('Test the widgets on the nutritional plan form', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(plan1)); await tester.pumpAndSettle(); @@ -78,8 +77,7 @@ void main() { expect(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME)), findsOneWidget); }); - testWidgets('Test editing an existing nutritional plan', - (WidgetTester tester) async { + testWidgets('Test editing an existing nutritional plan', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(plan1)); await tester.pumpAndSettle(); @@ -88,8 +86,7 @@ void main() { findsOneWidget, reason: 'Description of existing nutritional plan is filled in', ); - await tester.enterText( - find.byKey(Key('field-description')), 'New description'); + await tester.enterText(find.byKey(Key('field-description')), 'New description'); await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME))); // Correct method was called @@ -110,15 +107,12 @@ void main() { //); }); - testWidgets('Test creating a new nutritional plan', - (WidgetTester tester) async { + testWidgets('Test creating a new nutritional plan', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(plan2)); await tester.pumpAndSettle(); - expect(find.text(('')), findsOneWidget, - reason: 'New nutritional plan has no description'); - await tester.enterText( - find.byKey(Key('field-description')), 'New cool plan'); + expect(find.text(('')), findsOneWidget, reason: 'New nutritional plan has no description'); + await tester.enterText(find.byKey(Key('field-description')), 'New cool plan'); await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME))); // Correct method was called @@ -127,7 +121,6 @@ void main() { // Detail page await tester.pumpAndSettle(); - expect(find.text(('New cool plan')), findsOneWidget, - reason: 'Nutritional plan detail page'); + expect(find.text(('New cool plan')), findsOneWidget, reason: 'Nutritional plan detail page'); }); } diff --git a/test/nutritional_plan_form_test.mocks.dart b/test/nutritional_plan_form_test.mocks.dart index f98a58fd..e0cacce0 100644 --- a/test/nutritional_plan_form_test.mocks.dart +++ b/test/nutritional_plan_form_test.mocks.dart @@ -41,38 +41,35 @@ class _FakeResponse extends _i1.Fake implements _i8.Response {} /// A class which mocks [NutritionPlansProvider]. /// /// See the documentation for Mockito's code generation for more information. -class MockNutritionPlansProvider extends _i1.Mock - implements _i9.NutritionPlansProvider { +class MockNutritionPlansProvider extends _i1.Mock implements _i9.NutritionPlansProvider { MockNutritionPlansProvider() { _i1.throwOnMissingStub(this); } @override List<_i4.NutritionalPlan> get items => - (super.noSuchMethod(Invocation.getter(#items), - returnValue: <_i4.NutritionalPlan>[]) as List<_i4.NutritionalPlan>); + (super.noSuchMethod(Invocation.getter(#items), returnValue: <_i4.NutritionalPlan>[]) + as List<_i4.NutritionalPlan>); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) - as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i2.AuthProvider get auth => (super.noSuchMethod(Invocation.getter(#auth), - returnValue: _FakeAuthProvider()) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod(Invocation.getter(#auth), returnValue: _FakeAuthProvider()) + as _i2.AuthProvider); @override set auth(_i2.AuthProvider? _auth) => - super.noSuchMethod(Invocation.setter(#auth, _auth), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#auth, _auth), returnValueForMissingStub: null); @override - _i3.Client get client => (super.noSuchMethod(Invocation.getter(#client), - returnValue: _FakeClient()) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod(Invocation.getter(#client), returnValue: _FakeClient()) as _i3.Client); @override set client(_i3.Client? _client) => - super.noSuchMethod(Invocation.setter(#client, _client), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#client, _client), returnValueForMissingStub: null); @override _i4.NutritionalPlan findById(int? id) => - (super.noSuchMethod(Invocation.method(#findById, [id]), - returnValue: _FakeNutritionalPlan()) as _i4.NutritionalPlan); + (super.noSuchMethod(Invocation.method(#findById, [id]), returnValue: _FakeNutritionalPlan()) + as _i4.NutritionalPlan); @override _i5.Meal? findMealById(int? id) => (super.noSuchMethod(Invocation.method(#findMealById, [id])) as _i5.Meal?); @@ -89,20 +86,17 @@ class MockNutritionPlansProvider extends _i1.Mock @override _i10.Future<_i4.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod(Invocation.method(#fetchAndSetPlanSparse, [planId]), - returnValue: - Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) + returnValue: Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) as _i10.Future<_i4.NutritionalPlan>); @override _i10.Future<_i4.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod(Invocation.method(#fetchAndSetPlanFull, [planId]), - returnValue: - Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) + returnValue: Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) as _i10.Future<_i4.NutritionalPlan>); @override _i10.Future<_i4.NutritionalPlan> addPlan(_i4.NutritionalPlan? planData) => (super.noSuchMethod(Invocation.method(#addPlan, [planData]), - returnValue: - Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) + returnValue: Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan())) as _i10.Future<_i4.NutritionalPlan>); @override _i10.Future editPlan(_i4.NutritionalPlan? plan) => @@ -110,53 +104,44 @@ class MockNutritionPlansProvider extends _i1.Mock returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @override - _i10.Future deletePlan(int? id) => - (super.noSuchMethod(Invocation.method(#deletePlan, [id]), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i10.Future); + _i10.Future deletePlan(int? id) => (super.noSuchMethod(Invocation.method(#deletePlan, [id]), + returnValue: Future.value(null), + returnValueForMissingStub: Future.value()) as _i10.Future); @override _i10.Future<_i5.Meal> addMeal(_i5.Meal? meal, int? planId) => (super.noSuchMethod(Invocation.method(#addMeal, [meal, planId]), - returnValue: Future<_i5.Meal>.value(_FakeMeal())) - as _i10.Future<_i5.Meal>); + returnValue: Future<_i5.Meal>.value(_FakeMeal())) as _i10.Future<_i5.Meal>); @override _i10.Future<_i5.Meal> editMeal(_i5.Meal? meal) => (super.noSuchMethod(Invocation.method(#editMeal, [meal]), - returnValue: Future<_i5.Meal>.value(_FakeMeal())) - as _i10.Future<_i5.Meal>); + returnValue: Future<_i5.Meal>.value(_FakeMeal())) as _i10.Future<_i5.Meal>); @override _i10.Future deleteMeal(_i5.Meal? meal) => (super.noSuchMethod(Invocation.method(#deleteMeal, [meal]), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @override - _i10.Future<_i6.MealItem> addMealItem( - _i6.MealItem? mealItem, _i5.Meal? meal) => + _i10.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, _i5.Meal? meal) => (super.noSuchMethod(Invocation.method(#addMealItem, [mealItem, meal]), - returnValue: Future<_i6.MealItem>.value(_FakeMealItem())) - as _i10.Future<_i6.MealItem>); + returnValue: Future<_i6.MealItem>.value(_FakeMealItem())) as _i10.Future<_i6.MealItem>); @override _i10.Future deleteMealItem(_i6.MealItem? mealItem) => (super.noSuchMethod(Invocation.method(#deleteMealItem, [mealItem]), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @override - _i10.Future<_i7.Ingredient> fetchIngredient(int? ingredientId) => - (super.noSuchMethod(Invocation.method(#fetchIngredient, [ingredientId]), - returnValue: Future<_i7.Ingredient>.value(_FakeIngredient())) - as _i10.Future<_i7.Ingredient>); + _i10.Future<_i7.Ingredient> fetchIngredient(int? ingredientId) => (super.noSuchMethod( + Invocation.method(#fetchIngredient, [ingredientId]), + returnValue: Future<_i7.Ingredient>.value(_FakeIngredient())) as _i10.Future<_i7.Ingredient>); @override _i10.Future fetchIngredientsFromCache() => (super.noSuchMethod(Invocation.method(#fetchIngredientsFromCache, []), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @override - _i10.Future> searchIngredient(String? name, - [String? languageCode = r'en']) => - (super.noSuchMethod( - Invocation.method(#searchIngredient, [name, languageCode]), - returnValue: Future>.value([])) - as _i10.Future>); + _i10.Future> searchIngredient(String? name, [String? languageCode = r'en']) => + (super.noSuchMethod(Invocation.method(#searchIngredient, [name, languageCode]), + returnValue: Future>.value([])) as _i10.Future>); @override _i10.Future logMealToDiary(_i5.Meal? meal) => (super.noSuchMethod(Invocation.method(#logMealToDiary, [meal]), @@ -168,49 +153,41 @@ class MockNutritionPlansProvider extends _i1.Mock returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i10.Future); @override - void addListener(_i11.VoidCallback? listener) => - super.noSuchMethod(Invocation.method(#addListener, [listener]), - returnValueForMissingStub: null); + void addListener(_i11.VoidCallback? listener) => super + .noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override - void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), - returnValueForMissingStub: null); + void dispose() => + super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); @override void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); @override - Uri makeUrl(String? path, - {int? id, String? objectMethod, Map? query}) => + Uri makeUrl(String? path, {int? id, String? objectMethod, Map? query}) => (super.noSuchMethod( - Invocation.method(#makeUrl, [path], - {#id: id, #objectMethod: objectMethod, #query: query}), + Invocation.method( + #makeUrl, [path], {#id: id, #objectMethod: objectMethod, #query: query}), returnValue: _FakeUri()) as Uri); @override - _i10.Future> fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method(#fetch, [uri]), - returnValue: Future>.value({})) - as _i10.Future>); - @override - _i10.Future> post( - Map? data, Uri? uri) => - (super.noSuchMethod(Invocation.method(#post, [data, uri]), - returnValue: - Future>.value({})) + _i10.Future> fetch(Uri? uri) => + (super.noSuchMethod(Invocation.method(#fetch, [uri]), + returnValue: Future>.value({})) as _i10.Future>); @override - _i10.Future> patch( - Map? data, Uri? uri) => + _i10.Future> post(Map? data, Uri? uri) => + (super.noSuchMethod(Invocation.method(#post, [data, uri]), + returnValue: Future>.value({})) + as _i10.Future>); + @override + _i10.Future> patch(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#patch, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i10.Future>); @override _i10.Future<_i8.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(Invocation.method(#deleteRequest, [url, id]), - returnValue: Future<_i8.Response>.value(_FakeResponse())) - as _i10.Future<_i8.Response>); + returnValue: Future<_i8.Response>.value(_FakeResponse())) as _i10.Future<_i8.Response>); } diff --git a/test/nutritional_plan_model_test.dart b/test/nutritional_plan_model_test.dart index 03581674..2c69569c 100644 --- a/test/nutritional_plan_model_test.dart +++ b/test/nutritional_plan_model_test.dart @@ -25,16 +25,14 @@ void main() { group('model tests', () { test('Test the nutritionalValues method for nutritional plans', () { final plan = getNutritionalPlan(); - final values = NutritionalValues.values( - 4118.75, 28.75, 347.5, 9.5, 41.0, 31.75, 41.5, 30.0); + final values = NutritionalValues.values(4118.75, 28.75, 347.5, 9.5, 41.0, 31.75, 41.5, 30.0); expect(plan.nutritionalValues, values); }); test('Test the nutritionalValues method for meals', () { final plan = getNutritionalPlan(); final meal = plan.meals.first; - final values = NutritionalValues.values( - 518.75, 1.75, 17.5, 3.5, 11.0, 7.75, 38.5, 0.0); + final values = NutritionalValues.values(518.75, 1.75, 17.5, 3.5, 11.0, 7.75, 38.5, 0.0); expect(meal.nutritionalValues, values); }); }); diff --git a/test/nutritional_plan_screen_test.dart b/test/nutritional_plan_screen_test.dart index 8c9a1898..4a0461e5 100644 --- a/test/nutritional_plan_screen_test.dart +++ b/test/nutritional_plan_screen_test.dart @@ -55,8 +55,7 @@ void main() { ); } - testWidgets('Test the widgets on the nutritional plan screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the nutritional plan screen', (WidgetTester tester) async { await tester.pumpWidget(createNutritionalPlan()); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); @@ -73,8 +72,7 @@ void main() { expect(find.byType(NutritionalDiaryChartWidget), findsNothing); }); - testWidgets('Tests the localization of times - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of times - EN', (WidgetTester tester) async { await tester.pumpWidget(createNutritionalPlan()); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); @@ -82,8 +80,7 @@ void main() { expect(find.text('5:00 PM'), findsOneWidget); }); - testWidgets('Tests the localization of times - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of times - DE', (WidgetTester tester) async { await tester.pumpWidget(createNutritionalPlan(locale: 'de')); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); diff --git a/test/nutritional_plans_screen_test.dart b/test/nutritional_plans_screen_test.dart index 2f610cde..bef977a2 100644 --- a/test/nutritional_plans_screen_test.dart +++ b/test/nutritional_plans_screen_test.dart @@ -43,14 +43,8 @@ void main() { create: (context) => NutritionPlansProvider( testAuthProvider, [ - NutritionalPlan( - id: 1, - description: 'test plan 1', - creationDate: DateTime(2021, 01, 01)), - NutritionalPlan( - id: 2, - description: 'test plan 2', - creationDate: DateTime(2021, 01, 10)), + NutritionalPlan(id: 1, description: 'test plan 1', creationDate: DateTime(2021, 01, 01)), + NutritionalPlan(id: 2, description: 'test plan 2', creationDate: DateTime(2021, 01, 10)), ], client, ), @@ -66,8 +60,7 @@ void main() { ); } - testWidgets('Test the widgets on the nutritional plans screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the nutritional plans screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); //debugDumpApp(); @@ -76,8 +69,7 @@ void main() { expect(find.byType(ListTile), findsNWidgets(2)); }); - testWidgets('Test deleting an item by dragging the dismissible', - (WidgetTester tester) async { + testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0)); @@ -92,8 +84,7 @@ void main() { expect(find.byType(ListTile), findsOneWidget); }); - testWidgets('Test the form on the nutritional plan screen', - (WidgetTester tester) async { + testWidgets('Test the form on the nutritional plan screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.byType(PlanForm), findsNothing); @@ -102,16 +93,14 @@ void main() { expect(find.byType(PlanForm), findsOneWidget); }); - testWidgets('Tests the localization of dates - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.text('1/1/2021'), findsOneWidget); expect(find.text('1/10/2021'), findsOneWidget); }); - testWidgets('Tests the localization of dates - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); expect(find.text('1.1.2021'), findsOneWidget); diff --git a/test/nutritional_values_class_test.dart b/test/nutritional_values_class_test.dart index 8eb843bd..d818ba74 100644 --- a/test/nutritional_values_class_test.dart +++ b/test/nutritional_values_class_test.dart @@ -27,12 +27,9 @@ void main() { group('Test the NutritionalValues class', () { setUp(() { - values1 = NutritionalValues.values( - 4000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); - values2 = NutritionalValues.values( - 4000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); - values3 = NutritionalValues.values( - 5000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); + values1 = NutritionalValues.values(4000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); + values2 = NutritionalValues.values(4000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); + values3 = NutritionalValues.values(5000, 30.5, 340.5, 11.7, 41.0, 31.75, 21.3, 33.3); values4 = NutritionalValues.values(1000, 10, 100, 1, 10.0, 10, 10, 10); }); @@ -43,15 +40,13 @@ void main() { test('Test the plus operator', () { final values5 = values1 + values4; - final result = NutritionalValues.values( - 5000, 40.5, 440.5, 12.7, 51.0, 41.75, 31.3, 43.3); + final result = NutritionalValues.values(5000, 40.5, 440.5, 12.7, 51.0, 41.75, 31.3, 43.3); expect(values5, result); }); test('Test the add method', () { values1.add(values4); - final result = NutritionalValues.values( - 5000, 40.5, 440.5, 12.7, 51.0, 41.75, 31.3, 43.3); + final result = NutritionalValues.values(5000, 40.5, 440.5, 12.7, 51.0, 41.75, 31.3, 43.3); expect(values1, result); }); }); diff --git a/test/plate_calculator_test.dart b/test/plate_calculator_test.dart index 84927f53..e1150406 100644 --- a/test/plate_calculator_test.dart +++ b/test/plate_calculator_test.dart @@ -25,10 +25,8 @@ void main() { test('Regular weights', () async { expect(plateCalculator(40, BAR_WEIGHT, AVAILABLE_PLATES), [10]); expect(plateCalculator(100, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10]); - expect(plateCalculator(102.5, BAR_WEIGHT, AVAILABLE_PLATES), - [15, 15, 10, 1.25]); - expect( - plateCalculator(140, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 15, 15]); + expect(plateCalculator(102.5, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10, 1.25]); + expect(plateCalculator(140, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 15, 15]); expect(plateCalculator(45, BAR_WEIGHT, AVAILABLE_PLATES), [10, 2.5]); expect(plateCalculator(85, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 2.5]); }); diff --git a/test/weight_model_test.dart b/test/weight_model_test.dart index 64cf15f1..5b006206 100644 --- a/test/weight_model_test.dart +++ b/test/weight_model_test.dart @@ -21,23 +21,16 @@ import 'package:wger/models/body_weight/weight_entry.dart'; void main() { group('fetchPost', () { - test('Test that the weight entries are correctly converted to json', - () async { - WeightEntry weightEntry = - WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); - expect(weightEntry.toJson(), - {'id': 1, 'weight': '80', 'date': '2020-12-31'}); + test('Test that the weight entries are correctly converted to json', () async { + WeightEntry weightEntry = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); + expect(weightEntry.toJson(), {'id': 1, 'weight': '80', 'date': '2020-12-31'}); - weightEntry = - WeightEntry(id: 2, weight: 70.2, date: DateTime(2020, 12, 01)); - expect(weightEntry.toJson(), - {'id': 2, 'weight': '70.2', 'date': '2020-12-01'}); + weightEntry = WeightEntry(id: 2, weight: 70.2, date: DateTime(2020, 12, 01)); + expect(weightEntry.toJson(), {'id': 2, 'weight': '70.2', 'date': '2020-12-01'}); }); - test('Test that the weight entries are correctly converted from json', - () async { - WeightEntry weightEntryObj = - WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); + test('Test that the weight entries are correctly converted from json', () async { + WeightEntry weightEntryObj = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); WeightEntry weightEntry = WeightEntry.fromJson({ 'id': 1, 'weight': '80', @@ -53,8 +46,7 @@ void main() { test('Test the individual values from the model', () { WeightEntry _weightModel; //_weightModel = WeightEntry(); - _weightModel = - WeightEntry(id: 1, weight: 80, date: DateTime(2020, 10, 01)); + _weightModel = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 10, 01)); expect(_weightModel.id, 1); expect(_weightModel.weight, 80); diff --git a/test/weight_provider_test.dart b/test/weight_provider_test.dart index 65e2c9e1..706a6e92 100644 --- a/test/weight_provider_test.dart +++ b/test/weight_provider_test.dart @@ -41,8 +41,7 @@ void main() { 200)); // Load the entries - BodyWeightProvider provider = - BodyWeightProvider(testAuthProvider, [], client); + BodyWeightProvider provider = BodyWeightProvider(testAuthProvider, [], client); await provider.fetchAndSetEntries(); // Check that everything is ok @@ -60,14 +59,12 @@ void main() { headers: anyNamed('headers'), body: '{"id":null,"weight":"80","date":"2021-01-01"}', ), - ).thenAnswer((_) async => http.Response( - '{"id": 25, "date": "2021-01-01", "weight": "80"}', 200)); + ).thenAnswer( + (_) async => http.Response('{"id": 25, "date": "2021-01-01", "weight": "80"}', 200)); // POST the data to the server - final WeightEntry weightEntry = - WeightEntry(date: DateTime(2021, 1, 1), weight: 80); - final BodyWeightProvider provider = - BodyWeightProvider(testAuthProvider, [], client); + final WeightEntry weightEntry = WeightEntry(date: DateTime(2021, 1, 1), weight: 80); + final BodyWeightProvider provider = BodyWeightProvider(testAuthProvider, [], client); final WeightEntry weightEntryNew = await provider.addEntry(weightEntry); // Check that the server response is what we expect diff --git a/test/weight_screen_test.dart b/test/weight_screen_test.dart index 4adafcd1..018c9a80 100644 --- a/test/weight_screen_test.dart +++ b/test/weight_screen_test.dart @@ -43,8 +43,8 @@ void main() { any, headers: anyNamed('headers'), body: anyNamed('body'), - )).thenAnswer((_) async => - http.Response('{"id": 3, "date": "2021-01-01", "weight": "80"}', 200)); + )).thenAnswer( + (_) async => http.Response('{"id": 3, "date": "2021-01-01", "weight": "80"}', 200)); return ChangeNotifierProvider( create: (context) => BodyWeightProvider( @@ -67,8 +67,7 @@ void main() { ); } - testWidgets('Test the widgets on the body weight screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the body weight screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); //debugDumpApp(); @@ -78,8 +77,7 @@ void main() { expect(find.byType(ListTile), findsNWidgets(2)); }); - testWidgets('Test deleting an item by dragging the dismissible', - (WidgetTester tester) async { + testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0)); @@ -87,8 +85,7 @@ void main() { expect(find.byType(ListTile), findsOneWidget); }); - testWidgets('Test the form on the body weight screen', - (WidgetTester tester) async { + testWidgets('Test the form on the body weight screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.byType(WeightForm), findsNothing); @@ -97,16 +94,14 @@ void main() { expect(find.byType(WeightForm), findsOneWidget); }); - testWidgets('Tests the localization of dates - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.text('1/1/2021'), findsOneWidget); expect(find.text('1/10/2021'), findsOneWidget); }); - testWidgets('Tests the localization of dates - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); expect(find.text('1.1.2021'), findsOneWidget); diff --git a/test/workout_day_form_test.dart b/test/workout_day_form_test.dart index 1967f733..bfada4ec 100644 --- a/test/workout_day_form_test.dart +++ b/test/workout_day_form_test.dart @@ -56,8 +56,7 @@ void main() { ); } - testWidgets('Test the widgets on the DayFormWidget', - (WidgetTester tester) async { + testWidgets('Test the widgets on the DayFormWidget', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.pumpAndSettle(); @@ -67,14 +66,12 @@ void main() { }); testWidgets('Test creating a new day', (WidgetTester tester) async { - when(mockWorkoutPlans.addDay(any, any)) - .thenAnswer((_) => Future.value(Day())); + when(mockWorkoutPlans.addDay(any, any)).thenAnswer((_) => Future.value(Day())); await tester.pumpWidget(createHomeScreen()); await tester.pumpAndSettle(); - expect(find.text(('')), findsOneWidget, - reason: 'New day has no description'); + expect(find.text(('')), findsOneWidget, reason: 'New day has no description'); await tester.enterText(find.byKey(Key('field-description')), 'Leg day!'); await tester.tap(find.byKey(Key('field-checkbox-1'))); await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME))); @@ -86,8 +83,7 @@ void main() { //verify(mockObserver.didPop(any, any)); }); - testWidgets('Tests the localization of days - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of days - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.text('Monday'), findsOneWidget); @@ -95,8 +91,7 @@ void main() { expect(find.text('Thursday'), findsOneWidget); }); - testWidgets('Tests the localization of days - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of days - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); expect(find.text('Montag'), findsOneWidget); diff --git a/test/workout_form_test.dart b/test/workout_form_test.dart index 660e2f01..d524b425 100644 --- a/test/workout_form_test.dart +++ b/test/workout_form_test.dart @@ -44,8 +44,7 @@ void main() { setUp(() { mockWorkoutPlans = MockWorkoutPlansProvider(); - when(mockWorkoutPlans.editWorkout(any)) - .thenAnswer((_) => Future.value(existingPlan)); + when(mockWorkoutPlans.editWorkout(any)).thenAnswer((_) => Future.value(existingPlan)); when(mockWorkoutPlans.fetchAndSetWorkoutPlanFull(any)) .thenAnswer((_) => Future.value(existingPlan)); }); @@ -70,8 +69,7 @@ void main() { ); } - testWidgets('Test the widgets on the workout form', - (WidgetTester tester) async { + testWidgets('Test the widgets on the workout form', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(existingPlan)); await tester.pumpAndSettle(); @@ -109,22 +107,19 @@ void main() { //expect(find.text(('New description')), findsOneWidget, reason: 'Workout plan detail page'); }); - testWidgets('Test creating a new workout - only name', - (WidgetTester tester) async { + testWidgets('Test creating a new workout - only name', (WidgetTester tester) async { final editWorkout = WorkoutPlan( id: 2, creationDate: newPlan.creationDate, name: 'New cool workout', ); - when(mockWorkoutPlans.addWorkout(any)) - .thenAnswer((_) => Future.value(editWorkout)); + when(mockWorkoutPlans.addWorkout(any)).thenAnswer((_) => Future.value(editWorkout)); await tester.pumpWidget(createHomeScreen(newPlan)); await tester.pumpAndSettle(); - expect(find.text(('')), findsNWidgets(2), - reason: 'New workout has no name or description'); + expect(find.text(('')), findsNWidgets(2), reason: 'New workout has no name or description'); await tester.enterText(find.byKey(Key('field-name')), editWorkout.name); await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME))); @@ -133,28 +128,20 @@ void main() { // Detail page await tester.pumpAndSettle(); - expect(find.text(('New cool workout')), findsOneWidget, - reason: 'Workout plan detail page'); + expect(find.text(('New cool workout')), findsOneWidget, reason: 'Workout plan detail page'); }); - testWidgets('Test creating a new workout - name and description', - (WidgetTester tester) async { + testWidgets('Test creating a new workout - name and description', (WidgetTester tester) async { final editWorkout = WorkoutPlan( - id: 2, - creationDate: newPlan.creationDate, - name: 'My workout', - description: 'Get yuuuge'); - when(mockWorkoutPlans.addWorkout(any)) - .thenAnswer((_) => Future.value(editWorkout)); + id: 2, creationDate: newPlan.creationDate, name: 'My workout', description: 'Get yuuuge'); + when(mockWorkoutPlans.addWorkout(any)).thenAnswer((_) => Future.value(editWorkout)); await tester.pumpWidget(createHomeScreen(newPlan)); await tester.pumpAndSettle(); - expect(find.text(('')), findsNWidgets(2), - reason: 'New workout has no name or description'); + expect(find.text(('')), findsNWidgets(2), reason: 'New workout has no name or description'); await tester.enterText(find.byKey(Key('field-name')), editWorkout.name); - await tester.enterText( - find.byKey(Key('field-description')), editWorkout.description); + await tester.enterText(find.byKey(Key('field-description')), editWorkout.description); await tester.tap(find.byKey(Key(SUBMIT_BUTTON_KEY_NAME))); verifyNever(mockWorkoutPlans.editWorkout(any)); @@ -162,7 +149,6 @@ void main() { // Detail page await tester.pumpAndSettle(); - expect(find.text(('My workout')), findsOneWidget, - reason: 'Workout plan detail page'); + expect(find.text(('My workout')), findsOneWidget, reason: 'Workout plan detail page'); }); } diff --git a/test/workout_form_test.mocks.dart b/test/workout_form_test.mocks.dart index 5e35bf4c..9d790368 100644 --- a/test/workout_form_test.mocks.dart +++ b/test/workout_form_test.mocks.dart @@ -54,66 +54,60 @@ class _FakeResponse extends _i1.Fake implements _i12.Response {} /// A class which mocks [WorkoutPlansProvider]. /// /// See the documentation for Mockito's code generation for more information. -class MockWorkoutPlansProvider extends _i1.Mock - implements _i13.WorkoutPlansProvider { +class MockWorkoutPlansProvider extends _i1.Mock implements _i13.WorkoutPlansProvider { MockWorkoutPlansProvider() { _i1.throwOnMissingStub(this); } @override List<_i6.WorkoutPlan> get items => - (super.noSuchMethod(Invocation.getter(#items), - returnValue: <_i6.WorkoutPlan>[]) as List<_i6.WorkoutPlan>); + (super.noSuchMethod(Invocation.getter(#items), returnValue: <_i6.WorkoutPlan>[]) + as List<_i6.WorkoutPlan>); @override List<_i2.WeightUnit> get weightUnits => - (super.noSuchMethod(Invocation.getter(#weightUnits), - returnValue: <_i2.WeightUnit>[]) as List<_i2.WeightUnit>); + (super.noSuchMethod(Invocation.getter(#weightUnits), returnValue: <_i2.WeightUnit>[]) + as List<_i2.WeightUnit>); @override _i2.WeightUnit get defaultWeightUnit => - (super.noSuchMethod(Invocation.getter(#defaultWeightUnit), - returnValue: _FakeWeightUnit()) as _i2.WeightUnit); + (super.noSuchMethod(Invocation.getter(#defaultWeightUnit), returnValue: _FakeWeightUnit()) + as _i2.WeightUnit); @override List<_i3.RepetitionUnit> get repetitionUnits => - (super.noSuchMethod(Invocation.getter(#repetitionUnits), - returnValue: <_i3.RepetitionUnit>[]) as List<_i3.RepetitionUnit>); + (super.noSuchMethod(Invocation.getter(#repetitionUnits), returnValue: <_i3.RepetitionUnit>[]) + as List<_i3.RepetitionUnit>); @override _i3.RepetitionUnit get defaultRepetitionUnit => (super.noSuchMethod(Invocation.getter(#defaultRepetitionUnit), returnValue: _FakeRepetitionUnit()) as _i3.RepetitionUnit); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) - as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i4.AuthProvider get auth => (super.noSuchMethod(Invocation.getter(#auth), - returnValue: _FakeAuthProvider()) as _i4.AuthProvider); + _i4.AuthProvider get auth => + (super.noSuchMethod(Invocation.getter(#auth), returnValue: _FakeAuthProvider()) + as _i4.AuthProvider); @override set auth(_i4.AuthProvider? _auth) => - super.noSuchMethod(Invocation.setter(#auth, _auth), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#auth, _auth), returnValueForMissingStub: null); @override - _i5.Client get client => (super.noSuchMethod(Invocation.getter(#client), - returnValue: _FakeClient()) as _i5.Client); + _i5.Client get client => + (super.noSuchMethod(Invocation.getter(#client), returnValue: _FakeClient()) as _i5.Client); @override set client(_i5.Client? _client) => - super.noSuchMethod(Invocation.setter(#client, _client), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#client, _client), returnValueForMissingStub: null); @override _i6.WorkoutPlan findById(int? id) => - (super.noSuchMethod(Invocation.method(#findById, [id]), - returnValue: _FakeWorkoutPlan()) as _i6.WorkoutPlan); + (super.noSuchMethod(Invocation.method(#findById, [id]), returnValue: _FakeWorkoutPlan()) + as _i6.WorkoutPlan); @override - int findIndexById(int? id) => (super - .noSuchMethod(Invocation.method(#findIndexById, [id]), returnValue: 0) - as int); + int findIndexById(int? id) => + (super.noSuchMethod(Invocation.method(#findIndexById, [id]), returnValue: 0) as int); @override void setCurrentPlan(int? id) => - super.noSuchMethod(Invocation.method(#setCurrentPlan, [id]), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#setCurrentPlan, [id]), returnValueForMissingStub: null); @override void resetCurrentPlan() => - super.noSuchMethod(Invocation.method(#resetCurrentPlan, []), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#resetCurrentPlan, []), returnValueForMissingStub: null); @override _i14.Future fetchAndSetAllPlansFull() => (super.noSuchMethod(Invocation.method(#fetchAndSetAllPlansFull, []), @@ -131,8 +125,7 @@ class MockWorkoutPlansProvider extends _i1.Mock as _i14.Future<_i6.WorkoutPlan>); @override _i14.Future<_i6.WorkoutPlan> fetchAndSetWorkoutPlanFull(int? workoutId) => - (super.noSuchMethod( - Invocation.method(#fetchAndSetWorkoutPlanFull, [workoutId]), + (super.noSuchMethod(Invocation.method(#fetchAndSetWorkoutPlanFull, [workoutId]), returnValue: Future<_i6.WorkoutPlan>.value(_FakeWorkoutPlan())) as _i14.Future<_i6.WorkoutPlan>); @override @@ -154,8 +147,7 @@ class MockWorkoutPlansProvider extends _i1.Mock _i14.Future> fetchLogData( _i6.WorkoutPlan? workout, _i15.Exercise? exercise) => (super.noSuchMethod(Invocation.method(#fetchLogData, [workout, exercise]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i14.Future>); @override _i14.Future fetchAndSetRepetitionUnits() => @@ -175,27 +167,24 @@ class MockWorkoutPlansProvider extends _i1.Mock @override _i14.Future<_i7.Day> addDay(_i7.Day? day, _i6.WorkoutPlan? workout) => (super.noSuchMethod(Invocation.method(#addDay, [day, workout]), - returnValue: Future<_i7.Day>.value(_FakeDay())) - as _i14.Future<_i7.Day>); + returnValue: Future<_i7.Day>.value(_FakeDay())) as _i14.Future<_i7.Day>); @override _i14.Future deleteDay(_i7.Day? day) => (super.noSuchMethod(Invocation.method(#deleteDay, [day]), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i14.Future); @override - _i14.Future<_i8.Set> addSet(_i8.Set? workoutSet) => (super.noSuchMethod( - Invocation.method(#addSet, [workoutSet]), - returnValue: Future<_i8.Set>.value(_FakeSet())) as _i14.Future<_i8.Set>); + _i14.Future<_i8.Set> addSet(_i8.Set? workoutSet) => + (super.noSuchMethod(Invocation.method(#addSet, [workoutSet]), + returnValue: Future<_i8.Set>.value(_FakeSet())) as _i14.Future<_i8.Set>); @override - _i14.Future fetchComputedSettings(_i8.Set? workoutSet) => (super - .noSuchMethod(Invocation.method(#fetchComputedSettings, [workoutSet]), + _i14.Future fetchComputedSettings(_i8.Set? workoutSet) => + (super.noSuchMethod(Invocation.method(#fetchComputedSettings, [workoutSet]), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i14.Future); @override - _i14.Future fetchSmartText( - _i8.Set? workoutSet, _i15.Exercise? exercise) => - (super.noSuchMethod( - Invocation.method(#fetchSmartText, [workoutSet, exercise]), + _i14.Future fetchSmartText(_i8.Set? workoutSet, _i15.Exercise? exercise) => + (super.noSuchMethod(Invocation.method(#fetchSmartText, [workoutSet, exercise]), returnValue: Future.value('')) as _i14.Future); @override _i14.Future deleteSet(_i8.Set? workoutSet) => @@ -205,8 +194,7 @@ class MockWorkoutPlansProvider extends _i1.Mock @override _i14.Future<_i9.Setting> addSetting(_i9.Setting? workoutSetting) => (super.noSuchMethod(Invocation.method(#addSetting, [workoutSetting]), - returnValue: Future<_i9.Setting>.value(_FakeSetting())) - as _i14.Future<_i9.Setting>); + returnValue: Future<_i9.Setting>.value(_FakeSetting())) as _i14.Future<_i9.Setting>); @override _i14.Future fetchSessionData() => (super.noSuchMethod(Invocation.method(#fetchSessionData, []), @@ -214,58 +202,48 @@ class MockWorkoutPlansProvider extends _i1.Mock @override _i14.Future<_i10.WorkoutSession> addSession(_i10.WorkoutSession? session) => (super.noSuchMethod(Invocation.method(#addSession, [session]), - returnValue: - Future<_i10.WorkoutSession>.value(_FakeWorkoutSession())) + returnValue: Future<_i10.WorkoutSession>.value(_FakeWorkoutSession())) as _i14.Future<_i10.WorkoutSession>); @override _i14.Future<_i11.Log> addLog(_i11.Log? log) => (super.noSuchMethod(Invocation.method(#addLog, [log]), - returnValue: Future<_i11.Log>.value(_FakeLog())) - as _i14.Future<_i11.Log>); + returnValue: Future<_i11.Log>.value(_FakeLog())) as _i14.Future<_i11.Log>); @override - void addListener(_i16.VoidCallback? listener) => - super.noSuchMethod(Invocation.method(#addListener, [listener]), - returnValueForMissingStub: null); + void addListener(_i16.VoidCallback? listener) => super + .noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override - void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), - returnValueForMissingStub: null); + void dispose() => + super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); @override void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); @override - Uri makeUrl(String? path, - {int? id, String? objectMethod, Map? query}) => + Uri makeUrl(String? path, {int? id, String? objectMethod, Map? query}) => (super.noSuchMethod( - Invocation.method(#makeUrl, [path], - {#id: id, #objectMethod: objectMethod, #query: query}), + Invocation.method( + #makeUrl, [path], {#id: id, #objectMethod: objectMethod, #query: query}), returnValue: _FakeUri()) as Uri); @override - _i14.Future> fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method(#fetch, [uri]), - returnValue: Future>.value({})) - as _i14.Future>); - @override - _i14.Future> post( - Map? data, Uri? uri) => - (super.noSuchMethod(Invocation.method(#post, [data, uri]), - returnValue: - Future>.value({})) + _i14.Future> fetch(Uri? uri) => + (super.noSuchMethod(Invocation.method(#fetch, [uri]), + returnValue: Future>.value({})) as _i14.Future>); @override - _i14.Future> patch( - Map? data, Uri? uri) => + _i14.Future> post(Map? data, Uri? uri) => + (super.noSuchMethod(Invocation.method(#post, [data, uri]), + returnValue: Future>.value({})) + as _i14.Future>); + @override + _i14.Future> patch(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#patch, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i14.Future>); @override _i14.Future<_i12.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(Invocation.method(#deleteRequest, [url, id]), - returnValue: Future<_i12.Response>.value(_FakeResponse())) - as _i14.Future<_i12.Response>); + returnValue: Future<_i12.Response>.value(_FakeResponse())) as _i14.Future<_i12.Response>); } diff --git a/test/workout_plan_screen_test.dart b/test/workout_plan_screen_test.dart index e62be765..a2d98e63 100644 --- a/test/workout_plan_screen_test.dart +++ b/test/workout_plan_screen_test.dart @@ -33,8 +33,8 @@ void main() { final client = MockClient(); return ChangeNotifierProvider( - create: (context) => WorkoutPlansProvider( - testAuthProvider, testExercisesProvider, [], client), + create: (context) => + WorkoutPlansProvider(testAuthProvider, testExercisesProvider, [], client), child: MaterialApp( locale: Locale(locale), localizationsDelegates: AppLocalizations.localizationsDelegates, @@ -56,8 +56,7 @@ void main() { ); } - testWidgets('Test the widgets on the nutritional plan screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the nutritional plan screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); @@ -68,8 +67,7 @@ void main() { expect(find.byType(Dismissible), findsNWidgets(2)); }); - testWidgets('Tests the localization of times - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of times - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); @@ -78,8 +76,7 @@ void main() { expect(find.text('Thursday'), findsOneWidget); }); - testWidgets('Tests the localization of times - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of times - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); diff --git a/test/workout_plans_screen_test.dart b/test/workout_plans_screen_test.dart index fd8aed23..962f1c1b 100644 --- a/test/workout_plans_screen_test.dart +++ b/test/workout_plans_screen_test.dart @@ -45,10 +45,8 @@ void main() { testAuthProvider, testExercisesProvider, [ - WorkoutPlan( - id: 1, creationDate: DateTime(2021, 01, 01), name: 'test 1'), - WorkoutPlan( - id: 2, creationDate: DateTime(2021, 02, 12), name: 'test 2'), + WorkoutPlan(id: 1, creationDate: DateTime(2021, 01, 01), name: 'test 1'), + WorkoutPlan(id: 2, creationDate: DateTime(2021, 02, 12), name: 'test 2'), ], client, ), @@ -64,8 +62,7 @@ void main() { ); } - testWidgets('Test the widgets on the workout plans screen', - (WidgetTester tester) async { + testWidgets('Test the widgets on the workout plans screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); //debugDumpApp(); @@ -74,8 +71,7 @@ void main() { expect(find.byType(ListTile), findsNWidgets(2)); }); - testWidgets('Test deleting an item by dragging the dismissible', - (WidgetTester tester) async { + testWidgets('Test deleting an item by dragging the dismissible', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.drag(find.byKey(Key('1')), Offset(-500.0, 0.0)); @@ -90,8 +86,7 @@ void main() { expect(find.byType(ListTile), findsOneWidget); }); - testWidgets('Test the form on the workout plan screen', - (WidgetTester tester) async { + testWidgets('Test the form on the workout plan screen', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.byType(PlanForm), findsNothing); @@ -100,16 +95,14 @@ void main() { expect(find.byType(WorkoutForm), findsOneWidget); }); - testWidgets('Tests the localization of dates - EN', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); expect(find.text('1/1/2021'), findsOneWidget); expect(find.text('2/12/2021'), findsOneWidget); }); - testWidgets('Tests the localization of dates - DE', - (WidgetTester tester) async { + testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); expect(find.text('1.1.2021'), findsOneWidget); diff --git a/test/workout_set_form_test.dart b/test/workout_set_form_test.dart index f484b326..78a4f95f 100644 --- a/test/workout_set_form_test.dart +++ b/test/workout_set_form_test.dart @@ -74,8 +74,7 @@ void main() { ); } - testWidgets('Test the widgets on the SetFormWidget', - (WidgetTester tester) async { + testWidgets('Test the widgets on the SetFormWidget', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); await tester.pumpAndSettle(); @@ -87,12 +86,9 @@ void main() { }); testWidgets('Test creating a new set', (WidgetTester tester) async { - when(mockWorkoutPlans.addSet(any)) - .thenAnswer((_) => Future.value(Set.empty())); - when(mockWorkoutPlans.addSetting(any)) - .thenAnswer((_) => Future.value(Setting.empty())); - when(mockWorkoutPlans.fetchSmartText(any, any)) - .thenAnswer((_) => Future.value('2 x 10')); + when(mockWorkoutPlans.addSet(any)).thenAnswer((_) => Future.value(Set.empty())); + when(mockWorkoutPlans.addSetting(any)).thenAnswer((_) => Future.value(Setting.empty())); + when(mockWorkoutPlans.fetchSmartText(any, any)).thenAnswer((_) => Future.value('2 x 10')); await tester.pumpWidget(createHomeScreen()); await tester.pumpAndSettle(); diff --git a/test/workout_set_form_test.mocks.dart b/test/workout_set_form_test.mocks.dart index 0cc13095..6998005c 100644 --- a/test/workout_set_form_test.mocks.dart +++ b/test/workout_set_form_test.mocks.dart @@ -38,30 +38,29 @@ class MockExercisesProvider extends _i1.Mock implements _i6.ExercisesProvider { } @override - List<_i4.Exercise> get items => (super.noSuchMethod(Invocation.getter(#items), - returnValue: <_i4.Exercise>[]) as List<_i4.Exercise>); + List<_i4.Exercise> get items => + (super.noSuchMethod(Invocation.getter(#items), returnValue: <_i4.Exercise>[]) + as List<_i4.Exercise>); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) - as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i2.AuthProvider get auth => (super.noSuchMethod(Invocation.getter(#auth), - returnValue: _FakeAuthProvider()) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod(Invocation.getter(#auth), returnValue: _FakeAuthProvider()) + as _i2.AuthProvider); @override set auth(_i2.AuthProvider? _auth) => - super.noSuchMethod(Invocation.setter(#auth, _auth), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#auth, _auth), returnValueForMissingStub: null); @override - _i3.Client get client => (super.noSuchMethod(Invocation.getter(#client), - returnValue: _FakeClient()) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod(Invocation.getter(#client), returnValue: _FakeClient()) as _i3.Client); @override set client(_i3.Client? _client) => - super.noSuchMethod(Invocation.setter(#client, _client), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.setter(#client, _client), returnValueForMissingStub: null); @override _i4.Exercise findById(int? exerciseId) => - (super.noSuchMethod(Invocation.method(#findById, [exerciseId]), - returnValue: _FakeExercise()) as _i4.Exercise); + (super.noSuchMethod(Invocation.method(#findById, [exerciseId]), returnValue: _FakeExercise()) + as _i4.Exercise); @override _i7.Future fetchAndSetCategories() => (super.noSuchMethod(Invocation.method(#fetchAndSetCategories, []), @@ -80,63 +79,52 @@ class MockExercisesProvider extends _i1.Mock implements _i6.ExercisesProvider { @override _i7.Future<_i4.Exercise> fetchAndSetExercise(int? exerciseId) => (super.noSuchMethod(Invocation.method(#fetchAndSetExercise, [exerciseId]), - returnValue: Future<_i4.Exercise>.value(_FakeExercise())) - as _i7.Future<_i4.Exercise>); + returnValue: Future<_i4.Exercise>.value(_FakeExercise())) as _i7.Future<_i4.Exercise>); @override _i7.Future fetchAndSetExercises() => (super.noSuchMethod(Invocation.method(#fetchAndSetExercises, []), returnValue: Future.value(null), returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i7.Future> searchExercise(String? name, - [String? languageCode = r'en']) => - (super.noSuchMethod( - Invocation.method(#searchExercise, [name, languageCode]), - returnValue: Future>.value([])) - as _i7.Future>); + _i7.Future> searchExercise(String? name, [String? languageCode = r'en']) => + (super.noSuchMethod(Invocation.method(#searchExercise, [name, languageCode]), + returnValue: Future>.value([])) as _i7.Future>); @override - void addListener(_i8.VoidCallback? listener) => - super.noSuchMethod(Invocation.method(#addListener, [listener]), - returnValueForMissingStub: null); + void addListener(_i8.VoidCallback? listener) => super + .noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override - void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), - returnValueForMissingStub: null); + void dispose() => + super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); @override void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), - returnValueForMissingStub: null); + super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); @override - Uri makeUrl(String? path, - {int? id, String? objectMethod, Map? query}) => + Uri makeUrl(String? path, {int? id, String? objectMethod, Map? query}) => (super.noSuchMethod( - Invocation.method(#makeUrl, [path], - {#id: id, #objectMethod: objectMethod, #query: query}), + Invocation.method( + #makeUrl, [path], {#id: id, #objectMethod: objectMethod, #query: query}), returnValue: _FakeUri()) as Uri); @override - _i7.Future> fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method(#fetch, [uri]), - returnValue: Future>.value({})) - as _i7.Future>); + _i7.Future> fetch(Uri? uri) => + (super.noSuchMethod(Invocation.method(#fetch, [uri]), + returnValue: Future>.value({})) + as _i7.Future>); @override _i7.Future> post(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#post, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i7.Future>); @override - _i7.Future> patch( - Map? data, Uri? uri) => + _i7.Future> patch(Map? data, Uri? uri) => (super.noSuchMethod(Invocation.method(#patch, [data, uri]), - returnValue: - Future>.value({})) + returnValue: Future>.value({})) as _i7.Future>); @override _i7.Future<_i5.Response> deleteRequest(String? url, int? id) => (super.noSuchMethod(Invocation.method(#deleteRequest, [url, id]), - returnValue: Future<_i5.Response>.value(_FakeResponse())) - as _i7.Future<_i5.Response>); + returnValue: Future<_i5.Response>.value(_FakeResponse())) as _i7.Future<_i5.Response>); } diff --git a/test_data/body_weight.dart b/test_data/body_weight.dart index cb1f5fb9..409a1abd 100644 --- a/test_data/body_weight.dart +++ b/test_data/body_weight.dart @@ -18,7 +18,5 @@ import 'package:wger/models/body_weight/weight_entry.dart'; -final weightEntry1 = - WeightEntry(id: 1, weight: 80, date: DateTime(2021, 01, 01)); -final weightEntry2 = - WeightEntry(id: 2, weight: 81, date: DateTime(2021, 01, 10)); +final weightEntry1 = WeightEntry(id: 1, weight: 80, date: DateTime(2021, 01, 01)); +final weightEntry2 = WeightEntry(id: 2, weight: 81, date: DateTime(2021, 01, 10)); diff --git a/test_data/exercises.dart b/test_data/exercises.dart index db13c402..b49d29b6 100644 --- a/test_data/exercises.dart +++ b/test_data/exercises.dart @@ -63,8 +63,7 @@ final exercise3 = Exercise( uuid: 'a3b6c7bb-9d22-4119-a5fc-818584d5e9bc', creationDate: DateTime(2021, 4, 1), name: 'test exercise 3', - description: - 'The man in black fled across the desert, and the gunslinger followed', + description: 'The man in black fled across the desert, and the gunslinger followed', category: category3, categoryId: 3, muscles: [muscle1], diff --git a/test_data/workouts.dart b/test_data/workouts.dart index 3b970e4f..1f25abf8 100644 --- a/test_data/workouts.dart +++ b/test_data/workouts.dart @@ -29,8 +29,7 @@ import './exercises.dart'; const weightUnit1 = WeightUnit(id: 1, name: 'kg'); const weightUnit2 = WeightUnit(id: 2, name: 'metric tonnes'); -const RepetitionUnit repetitionUnit1 = - RepetitionUnit(id: 1, name: 'Repetitions'); +const RepetitionUnit repetitionUnit1 = RepetitionUnit(id: 1, name: 'Repetitions'); const RepetitionUnit repetitionUnit2 = RepetitionUnit(id: 2, name: 'Hours'); WorkoutPlan getWorkout() {