diff --git a/analysis_options.yaml b/analysis_options.yaml index 68c186a1..b7abc707 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -21,6 +21,7 @@ analyzer: formatter: page_width: 100 + trailing_commas: preserve linter: rules: diff --git a/integration_test/1_dashboard.dart b/integration_test/1_dashboard.dart index 5714320c..7580b828 100644 --- a/integration_test/1_dashboard.dart +++ b/integration_test/1_dashboard.dart @@ -25,23 +25,27 @@ import '../test_data/routines.dart'; Widget createDashboardScreen({String locale = 'en'}) { final mockWorkoutProvider = MockRoutinesProvider(); when(mockWorkoutProvider.items).thenReturn([getTestRoutine(exercises: getScreenshotExercises())]); - when(mockWorkoutProvider.currentRoutine) - .thenReturn(getTestRoutine(exercises: getScreenshotExercises())); + when( + mockWorkoutProvider.currentRoutine, + ).thenReturn(getTestRoutine(exercises: getScreenshotExercises())); - when(mockWorkoutProvider.fetchSessionData()).thenAnswer((a) => Future.value([ - WorkoutSession( - routineId: 1, - date: DateTime.now().add(const Duration(days: -1)), - timeStart: const TimeOfDay(hour: 17, minute: 34), - timeEnd: const TimeOfDay(hour: 19, minute: 3), - impression: 3, - ), - ])); + when(mockWorkoutProvider.fetchSessionData()).thenAnswer( + (a) => Future.value([ + WorkoutSession( + routineId: 1, + date: DateTime.now().add(const Duration(days: -1)), + timeStart: const TimeOfDay(hour: 17, minute: 34), + timeEnd: const TimeOfDay(hour: 19, minute: 3), + impression: 3, + ), + ]), + ); final mockNutritionProvider = weight.MockNutritionPlansProvider(); - when(mockNutritionProvider.currentPlan) - .thenAnswer((realInvocation) => getNutritionalPlanScreenshot()); + when( + mockNutritionProvider.currentPlan, + ).thenAnswer((realInvocation) => getNutritionalPlanScreenshot()); when(mockNutritionProvider.items).thenReturn([getNutritionalPlanScreenshot()]); final mockWeightProvider = weight.MockBodyWeightProvider(); diff --git a/integration_test/make_screenshots_test.dart b/integration_test/make_screenshots_test.dart index c4a94e68..3d475363 100644 --- a/integration_test/make_screenshots_test.dart +++ b/integration_test/make_screenshots_test.dart @@ -17,7 +17,7 @@ enum DeviceType { sevenInchScreenshots, tenInchScreenshots, tvScreenshots, - wearScreenshots + wearScreenshots, } final destination = DeviceType.phoneScreenshots.name; @@ -42,7 +42,6 @@ Future takeScreenshot( const languages = [ // Note: it seems if too many languages are processed at once, some processes // disappear and no images are written. Doing this in smaller steps works fine - 'ar', 'ca', 'cs-CZ', diff --git a/lib/database/exercises/exercise_database.dart b/lib/database/exercises/exercise_database.dart index 35a3eaf2..e7c36a6e 100644 --- a/lib/database/exercises/exercise_database.dart +++ b/lib/database/exercises/exercise_database.dart @@ -85,20 +85,20 @@ class ExerciseDatabase extends _$ExerciseDatabase { /// will fetch everything as needed from the server @override MigrationStrategy get migration => MigrationStrategy( - onUpgrade: (m, from, to) async { - // no-op, but needs to be defined - return; - }, - beforeOpen: (openingDetails) async { - if (openingDetails.hadUpgrade) { - final m = createMigrator(); - for (final table in allTables) { - await m.deleteTable(table.actualTableName); - await m.createTable(table); - } - } - }, - ); + onUpgrade: (m, from, to) async { + // no-op, but needs to be defined + return; + }, + beforeOpen: (openingDetails) async { + if (openingDetails.hadUpgrade) { + final m = createMigrator(); + for (final table in allTables) { + await m.deleteTable(table.actualTableName); + await m.createTable(table); + } + } + }, + ); Future deleteEverything() { return transaction(() async { diff --git a/lib/database/ingredients/ingredients_database.dart b/lib/database/ingredients/ingredients_database.dart index cd14ea9e..28f839ed 100644 --- a/lib/database/ingredients/ingredients_database.dart +++ b/lib/database/ingredients/ingredients_database.dart @@ -38,20 +38,20 @@ class IngredientDatabase extends _$IngredientDatabase { /// will fetch everything as needed from the server @override MigrationStrategy get migration => MigrationStrategy( - onUpgrade: (m, from, to) async { - // no-op, but needs to be defined - return; - }, - beforeOpen: (openingDetails) async { - if (openingDetails.hadUpgrade) { - final m = createMigrator(); - for (final table in allTables) { - await m.deleteTable(table.actualTableName); - await m.createTable(table); - } - } - }, - ); + onUpgrade: (m, from, to) async { + // no-op, but needs to be defined + return; + }, + beforeOpen: (openingDetails) async { + if (openingDetails.hadUpgrade) { + final m = createMigrator(); + for (final table in allTables) { + await m.deleteTable(table.actualTableName); + await m.createTable(table); + } + } + }, + ); Future deleteEverything() { return transaction(() async { diff --git a/lib/helpers/measurements.dart b/lib/helpers/measurements.dart index f3cd5462..bcde38fb 100644 --- a/lib/helpers/measurements.dart +++ b/lib/helpers/measurements.dart @@ -25,11 +25,11 @@ extension MeasurementChartEntryListExtensions on List { return where((e) => e.date.isAfter(start) && (end == null || e.date.isBefore(end))).toList(); } -// assures values on the start (and optionally end) dates exist, by interpolating if needed -// this is used for when you are looking at a specific time frame (e.g. for a nutrition plan) -// while gaps in the middle of a chart can be "visually interpolated", it's good to have a clearer -// explicit interpolation for the start and end dates (if needed) -// this also helps with computing delta's across the entire window + // assures values on the start (and optionally end) dates exist, by interpolating if needed + // this is used for when you are looking at a specific time frame (e.g. for a nutrition plan) + // while gaps in the middle of a chart can be "visually interpolated", it's good to have a clearer + // explicit interpolation for the start and end dates (if needed) + // this also helps with computing delta's across the entire window List whereDateWithInterpolation(DateTime start, DateTime? end) { // Make sure our list is sorted by date sort((a, b) => a.date.compareTo(b.date)); @@ -90,7 +90,10 @@ extension MeasurementChartEntryListExtensions on List { // caller needs to make sure that before.date < date < after.date MeasurementChartEntry interpolateBetween( - MeasurementChartEntry before, MeasurementChartEntry after, DateTime date) { + MeasurementChartEntry before, + MeasurementChartEntry after, + DateTime date, +) { final totalDuration = after.date.difference(before.date).inMilliseconds; final startDuration = date.difference(before.date).inMilliseconds; diff --git a/lib/main.dart b/lib/main.dart index 216e881f..db8836c1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -146,8 +146,8 @@ class MainApp extends StatelessWidget { future: auth.tryAutoLogin(), builder: (ctx, authResultSnapshot) => authResultSnapshot.connectionState == ConnectionState.waiting - ? const SplashScreen() - : const AuthScreen(), + ? const SplashScreen() + : const AuthScreen(), ); } } diff --git a/lib/models/body_weight/weight_entry.dart b/lib/models/body_weight/weight_entry.dart index 827ccf7d..d5343cd6 100644 --- a/lib/models/body_weight/weight_entry.dart +++ b/lib/models/body_weight/weight_entry.dart @@ -41,10 +41,10 @@ class WeightEntry { } WeightEntry copyWith({int? id, int? weight, DateTime? date}) => WeightEntry( - id: id, - weight: weight ?? this.weight, - date: date ?? this.date, - ); + id: id, + weight: weight ?? this.weight, + date: date ?? this.date, + ); // Boilerplate factory WeightEntry.fromJson(Map json) => _$WeightEntryFromJson(json); diff --git a/lib/models/exercises/exercise.dart b/lib/models/exercises/exercise.dart index aae54832..31af9753 100644 --- a/lib/models/exercises/exercise.dart +++ b/lib/models/exercises/exercise.dart @@ -145,10 +145,10 @@ class Exercise extends Equatable { } Exercise.fromApiDataString(String baseData, List languages) - : this.fromApiData(ExerciseApiData.fromString(baseData), languages); + : this.fromApiData(ExerciseApiData.fromString(baseData), languages); Exercise.fromApiDataJson(Map baseData, List languages) - : this.fromApiData(ExerciseApiData.fromJson(baseData), languages); + : this.fromApiData(ExerciseApiData.fromJson(baseData), languages); Exercise.fromApiData(ExerciseApiData exerciseData, List languages) { id = exerciseData.id; @@ -228,13 +228,13 @@ class Exercise extends Equatable { @override List get props => [ - id, - uuid, - created, - lastUpdate, - category, - equipment, - muscles, - musclesSecondary, - ]; + id, + uuid, + created, + lastUpdate, + category, + equipment, + muscles, + musclesSecondary, + ]; } diff --git a/lib/models/exercises/translation.dart b/lib/models/exercises/translation.dart index 1767501a..0fc40534 100644 --- a/lib/models/exercises/translation.dart +++ b/lib/models/exercises/translation.dart @@ -92,12 +92,12 @@ class Translation extends Equatable { @override List get props => [ - id, - exerciseId, - uuid, - languageId, - created, - name, - description, - ]; + id, + exerciseId, + uuid, + languageId, + created, + name, + description, + ]; } diff --git a/lib/models/measurements/measurement_entry.g.dart b/lib/models/measurements/measurement_entry.g.dart index a0c73b73..f8eebb7d 100644 --- a/lib/models/measurements/measurement_entry.g.dart +++ b/lib/models/measurements/measurement_entry.g.dart @@ -20,11 +20,10 @@ MeasurementEntry _$MeasurementEntryFromJson(Map json) { ); } -Map _$MeasurementEntryToJson(MeasurementEntry instance) => - { - 'id': instance.id, - 'category': instance.category, - 'date': dateToYYYYMMDD(instance.date), - 'value': instance.value, - 'notes': instance.notes, - }; +Map _$MeasurementEntryToJson(MeasurementEntry instance) => { + 'id': instance.id, + 'category': instance.category, + 'date': dateToYYYYMMDD(instance.date), + 'value': instance.value, + 'notes': instance.notes, +}; diff --git a/lib/models/nutrition/log.dart b/lib/models/nutrition/log.dart index d36e5a53..259c43a0 100644 --- a/lib/models/nutrition/log.dart +++ b/lib/models/nutrition/log.dart @@ -84,8 +84,9 @@ class Log { NutritionalValues get nutritionalValues { // This is already done on the server. It might be better to read it from there. - final weight = - weightUnitObj == null ? amount : amount * weightUnitObj!.amount * weightUnitObj!.grams; + final weight = weightUnitObj == null + ? amount + : amount * weightUnitObj!.amount * weightUnitObj!.grams; return ingredient.nutritionalValues / (100 / weight); } diff --git a/lib/models/nutrition/nutritional_goals.dart b/lib/models/nutrition/nutritional_goals.dart index 7a668a46..cca69674 100644 --- a/lib/models/nutrition/nutritional_goals.dart +++ b/lib/models/nutrition/nutritional_goals.dart @@ -57,7 +57,8 @@ class NutritionalGoals { (energy! - protein! * ENERGY_PROTEIN - fat! * ENERGY_FAT) / ENERGY_CARBOHYDRATES; assert(carbohydrates! > 0); } else if (fat == null && protein != null && carbohydrates != null) { - fat = (energy! - protein! * ENERGY_PROTEIN - carbohydrates! * ENERGY_CARBOHYDRATES) / + fat = + (energy! - protein! * ENERGY_PROTEIN - carbohydrates! * ENERGY_CARBOHYDRATES) / ENERGY_FAT; assert(fat! > 0); } @@ -141,15 +142,15 @@ class NutritionalGoals { @override //ignore: avoid_equals_and_hash_code_on_mutable_classes int get hashCode => Object.hash( - energy, - protein, - carbohydrates, - carbohydratesSugar, - fat, - fatSaturated, - fiber, - sodium, - ); + energy, + protein, + carbohydrates, + carbohydratesSugar, + fat, + fatSaturated, + fiber, + sodium, + ); @override // ignore: avoid_equals_and_hash_code_on_mutable_classes diff --git a/lib/models/nutrition/nutritional_values.dart b/lib/models/nutrition/nutritional_values.dart index fee6c370..1cb5c7fe 100644 --- a/lib/models/nutrition/nutritional_values.dart +++ b/lib/models/nutrition/nutritional_values.dart @@ -132,13 +132,13 @@ class NutritionalValues { @override //ignore: avoid_equals_and_hash_code_on_mutable_classes int get hashCode => Object.hash( - energy, - protein, - carbohydrates, - carbohydratesSugar, - fat, - fatSaturated, - fiber, - sodium, - ); + energy, + protein, + carbohydrates, + carbohydratesSugar, + fat, + fatSaturated, + fiber, + sodium, + ); } diff --git a/lib/models/nutrition/weight_unit.g.dart b/lib/models/nutrition/weight_unit.g.dart index af7c8bed..a8f86e6d 100644 --- a/lib/models/nutrition/weight_unit.g.dart +++ b/lib/models/nutrition/weight_unit.g.dart @@ -14,5 +14,7 @@ WeightUnit _$WeightUnitFromJson(Map json) { ); } -Map _$WeightUnitToJson(WeightUnit instance) => - {'id': instance.id, 'name': instance.name}; +Map _$WeightUnitToJson(WeightUnit instance) => { + 'id': instance.id, + 'name': instance.name, +}; diff --git a/lib/models/workouts/base_config.g.dart b/lib/models/workouts/base_config.g.dart index c97f3899..a3513312 100644 --- a/lib/models/workouts/base_config.g.dart +++ b/lib/models/workouts/base_config.g.dart @@ -32,13 +32,12 @@ BaseConfig _$BaseConfigFromJson(Map json) { ); } -Map _$BaseConfigToJson(BaseConfig instance) => - { - 'slot_entry': instance.slotEntryId, - 'iteration': instance.iteration, - 'value': instance.value, - 'operation': instance.operation, - 'step': instance.step, - 'repeat': instance.repeat, - 'requirements': instance.requirements, - }; +Map _$BaseConfigToJson(BaseConfig instance) => { + 'slot_entry': instance.slotEntryId, + 'iteration': instance.iteration, + 'value': instance.value, + 'operation': instance.operation, + 'step': instance.step, + 'repeat': instance.repeat, + 'requirements': instance.requirements, +}; diff --git a/lib/models/workouts/log.dart b/lib/models/workouts/log.dart index 3931d321..f3ccfb81 100644 --- a/lib/models/workouts/log.dart +++ b/lib/models/workouts/log.dart @@ -142,8 +142,13 @@ class Log { /// Returns the text representation for a single setting, used in the gym mode String get singleLogRepTextNoNl { - return repText(repetitions, repetitionsUnitObj, weight, weightUnitObj, rir) - .replaceAll('\n', ''); + return repText( + repetitions, + repetitionsUnitObj, + weight, + weightUnitObj, + rir, + ).replaceAll('\n', ''); } /// Override the equals operator diff --git a/lib/models/workouts/repetition_unit.g.dart b/lib/models/workouts/repetition_unit.g.dart index d234bc55..679c55ef 100644 --- a/lib/models/workouts/repetition_unit.g.dart +++ b/lib/models/workouts/repetition_unit.g.dart @@ -14,5 +14,7 @@ RepetitionUnit _$RepetitionUnitFromJson(Map json) { ); } -Map _$RepetitionUnitToJson(RepetitionUnit instance) => - {'id': instance.id, 'name': instance.name}; +Map _$RepetitionUnitToJson(RepetitionUnit instance) => { + 'id': instance.id, + 'name': instance.name, +}; diff --git a/lib/models/workouts/weight_unit.g.dart b/lib/models/workouts/weight_unit.g.dart index af7c8bed..a8f86e6d 100644 --- a/lib/models/workouts/weight_unit.g.dart +++ b/lib/models/workouts/weight_unit.g.dart @@ -14,5 +14,7 @@ WeightUnit _$WeightUnitFromJson(Map json) { ); } -Map _$WeightUnitToJson(WeightUnit instance) => - {'id': instance.id, 'name': instance.name}; +Map _$WeightUnitToJson(WeightUnit instance) => { + 'id': instance.id, + 'name': instance.name, +}; diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index dd569ade..a00a292a 100644 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -251,7 +251,7 @@ class AuthProvider with ChangeNotifier { headers: { HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8', HttpHeaders.userAgentHeader: getAppNameHeader(), - HttpHeaders.authorizationHeader: 'Token $token' + HttpHeaders.authorizationHeader: 'Token $token', }, ); if (response.statusCode != 200) { @@ -294,7 +294,8 @@ class AuthProvider with ChangeNotifier { String getAppNameHeader() { String out = ''; if (applicationVersion != null) { - out = '/${applicationVersion!.version} ' + out = + '/${applicationVersion!.version} ' '(${applicationVersion!.packageName}; ' 'build: ${applicationVersion!.buildNumber})' ' - https://github.com/wger-project'; diff --git a/lib/providers/body_weight.dart b/lib/providers/body_weight.dart index 9aa52c27..dddb8cec 100644 --- a/lib/providers/body_weight.dart +++ b/lib/providers/body_weight.dart @@ -68,10 +68,12 @@ class BodyWeightProvider with ChangeNotifier { _logger.info('Fetching all body weight entries'); // Process the response - final data = await baseProvider.fetchPaginated(baseProvider.makeUrl( - BODY_WEIGHT_URL, - query: {'ordering': '-date', 'limit': API_MAX_PAGE_SIZE}, - )); + final data = await baseProvider.fetchPaginated( + baseProvider.makeUrl( + BODY_WEIGHT_URL, + query: {'ordering': '-date', 'limit': API_MAX_PAGE_SIZE}, + ), + ); _entries = []; for (final entry in data) { _entries.add(WeightEntry.fromJson(entry)); diff --git a/lib/providers/gym_state.dart b/lib/providers/gym_state.dart index b208f806..659cc525 100644 --- a/lib/providers/gym_state.dart +++ b/lib/providers/gym_state.dart @@ -8,8 +8,8 @@ const DEFAULT_DURATION = Duration(hours: 5); final StateNotifierProvider gymStateProvider = StateNotifierProvider((ref) { - return GymStateNotifier(); -}); + return GymStateNotifier(); + }); class GymState { final Map exercisePages; @@ -19,13 +19,14 @@ class GymState { late TimeOfDay startTime; late DateTime validUntil; - GymState( - {this.exercisePages = const {}, - this.showExercisePages = true, - this.currentPage = 0, - this.dayId, - DateTime? validUntil, - TimeOfDay? startTime}) { + GymState({ + this.exercisePages = const {}, + this.showExercisePages = true, + this.currentPage = 0, + this.dayId, + DateTime? validUntil, + TimeOfDay? startTime, + }) { this.validUntil = validUntil ?? DateTime.now().add(DEFAULT_DURATION); this.startTime = startTime ?? TimeOfDay.fromDateTime(clock.now()); } diff --git a/lib/providers/measurement.dart b/lib/providers/measurement.dart index faa07699..c961e938 100644 --- a/lib/providers/measurement.dart +++ b/lib/providers/measurement.dart @@ -133,8 +133,9 @@ class MeasurementProvider with ChangeNotifier { tempNewCategory.toJson(), baseProvider.makeUrl(_categoryUrl, id: id), ); - final MeasurementCategory newCategory = - MeasurementCategory.fromJson(response).copyWith(entries: oldCategory.entries); + final MeasurementCategory newCategory = MeasurementCategory.fromJson( + response, + ).copyWith(entries: oldCategory.entries); _categories.removeAt(categoryIndex); _categories.insert(categoryIndex, newCategory); notifyListeners(); @@ -192,8 +193,10 @@ class MeasurementProvider with ChangeNotifier { date: newDate, ); - final Map response = - await baseProvider.patch(tempNewEntry.toJson(), baseProvider.makeUrl(_entryUrl, id: id)); + final Map response = await baseProvider.patch( + tempNewEntry.toJson(), + baseProvider.makeUrl(_entryUrl, id: id), + ); final MeasurementEntry newEntry = MeasurementEntry.fromJson(response); category.entries.removeAt(entryIndex); diff --git a/lib/providers/plate_weights.dart b/lib/providers/plate_weights.dart index 51747d72..55a6e20b 100644 --- a/lib/providers/plate_weights.dart +++ b/lib/providers/plate_weights.dart @@ -18,8 +18,8 @@ const PREFS_KEY_PLATES = 'selectedPlates'; final plateCalculatorProvider = StateNotifierProvider((ref) { - return PlateCalculatorNotifier(); -}); + return PlateCalculatorNotifier(); + }); class PlateCalculatorState { final _logger = Logger('PlateWeightsState'); @@ -65,17 +65,18 @@ class PlateCalculatorState { this.isMetric = true, this.totalWeight = 0, List? selectedPlates, - }) : barWeight = barWeight ?? (isMetric ? DEFAULT_BAR_WEIGHT_KG : DEFAULT_BAR_WEIGHT_LB), - selectedPlates = - selectedPlates ?? (isMetric ? [...DEFAULT_KG_PLATES] : [...DEFAULT_LB_PLATES]); + }) : barWeight = barWeight ?? (isMetric ? DEFAULT_BAR_WEIGHT_KG : DEFAULT_BAR_WEIGHT_LB), + selectedPlates = + selectedPlates ?? (isMetric ? [...DEFAULT_KG_PLATES] : [...DEFAULT_LB_PLATES]); PlateCalculatorState.fromJson(Map plateData) - : useColors = plateData['useColors'] ?? true, - isMetric = plateData['isMetric'] ?? true, - selectedPlates = plateData['selectedPlates']?.cast() ?? [...DEFAULT_KG_PLATES], - barWeight = plateData['barWeight'] ?? - ((plateData['isMetric'] ?? true) ? DEFAULT_BAR_WEIGHT_KG : DEFAULT_BAR_WEIGHT_LB), - totalWeight = 0; + : useColors = plateData['useColors'] ?? true, + isMetric = plateData['isMetric'] ?? true, + selectedPlates = plateData['selectedPlates']?.cast() ?? [...DEFAULT_KG_PLATES], + barWeight = + plateData['barWeight'] ?? + ((plateData['isMetric'] ?? true) ? DEFAULT_BAR_WEIGHT_KG : DEFAULT_BAR_WEIGHT_LB), + totalWeight = 0; PlateCalculatorState copyWith({ bool? useColors, diff --git a/lib/providers/routines.dart b/lib/providers/routines.dart index 7c124274..ec8e53b9 100644 --- a/lib/providers/routines.dart +++ b/lib/providers/routines.dart @@ -279,8 +279,9 @@ class RoutinesProvider with ChangeNotifier { final dayDataEntriesGym = dayDataGym.map((entry) => DayData.fromJson(entry)).toList(); await setExercisesAndUnits(dayDataEntriesGym, exercises: exercises); - final sessionDataEntries = - sessionData.map((entry) => WorkoutSessionApi.fromJson(entry)).toList(); + final sessionDataEntries = sessionData + .map((entry) => WorkoutSessionApi.fromJson(entry)) + .toList(); for (final day in routine.days) { for (final slot in day.slots) { @@ -322,8 +323,9 @@ class RoutinesProvider with ChangeNotifier { } if (!exercises.containsKey(log.exerciseId)) { - exercises[log.exerciseId] = - (await _exerciseProvider.fetchAndSetExercise(log.exerciseId))!; + exercises[log.exerciseId] = (await _exerciseProvider.fetchAndSetExercise( + log.exerciseId, + ))!; } log.exerciseBase = exercises[log.exerciseId]!; @@ -378,8 +380,9 @@ class RoutinesProvider with ChangeNotifier { /// Fetch and set weight units for workout (kg, lb, plate, etc.) Future fetchAndSetRepetitionUnits() async { - final response = - await baseProvider.fetchPaginated(baseProvider.makeUrl(_repetitionUnitUrlPath)); + final response = await baseProvider.fetchPaginated( + baseProvider.makeUrl(_repetitionUnitUrlPath), + ); for (final unit in response) { _repetitionUnits.add(RepetitionUnit.fromJson(unit)); } diff --git a/lib/providers/user.dart b/lib/providers/user.dart index fc8959d1..3765bfe2 100644 --- a/lib/providers/user.dart +++ b/lib/providers/user.dart @@ -101,10 +101,12 @@ class UserProvider with ChangeNotifier { /// Verify the user's email Future verifyEmail() async { - await baseProvider.fetch(baseProvider.makeUrl( - PROFILE_URL, - objectMethod: VERIFY_EMAIL, - )); + await baseProvider.fetch( + baseProvider.makeUrl( + PROFILE_URL, + objectMethod: VERIFY_EMAIL, + ), + ); //log(verificationData.toString()); } } diff --git a/lib/screens/auth_screen.dart b/lib/screens/auth_screen.dart index 1de4967b..ce036a4f 100644 --- a/lib/screens/auth_screen.dart +++ b/lib/screens/auth_screen.dart @@ -182,11 +182,11 @@ class _AuthCardState extends State { late LoginActions res; if (_authMode == AuthMode.Login) { res = await context.read().login( - _authData['username']!, - _authData['password']!, - _authData['serverUrl']!, - _authData['apiToken'], - ); + _authData['username']!, + _authData['password']!, + _authData['serverUrl']!, + _authData['apiToken'], + ); // Register new user } else { @@ -287,8 +287,9 @@ class _AuthCardState extends State { labelText: i18n.confirmPassword, prefixIcon: const Icon(Icons.password), suffixIcon: IconButton( - icon: - Icon(confirmIsObscure ? Icons.visibility_off : Icons.visibility), + icon: Icon( + confirmIsObscure ? Icons.visibility_off : Icons.visibility, + ), onPressed: () { updateState(() { confirmIsObscure = !confirmIsObscure; @@ -374,8 +375,9 @@ class _AuthCardState extends State { Builder( key: const Key('toggleActionButton'), builder: (context) { - final String text = - _authMode != AuthMode.Register ? i18n.registerInstead : i18n.loginInstead; + final String text = _authMode != AuthMode.Register + ? i18n.registerInstead + : i18n.loginInstead; return GestureDetector( onTap: () => _switchAuthMode(), diff --git a/lib/screens/gym_mode.dart b/lib/screens/gym_mode.dart index 6137fa9a..8e28b527 100644 --- a/lib/screens/gym_mode.dart +++ b/lib/screens/gym_mode.dart @@ -40,8 +40,9 @@ class GymModeScreen extends StatelessWidget { final routinesProvider = context.read(); final routine = routinesProvider.findById(args.routineId); - final dayDataDisplay = - routine.dayData.firstWhere((e) => e.iteration == args.iteration && e.day?.id == args.dayId); + final dayDataDisplay = routine.dayData.firstWhere( + (e) => e.iteration == args.iteration && e.day?.id == args.dayId, + ); final dayDataGym = routine.dayDataGym .where((e) => e.iteration == args.iteration && e.day?.id == args.dayId) .first; diff --git a/lib/screens/nutritional_plan_screen.dart b/lib/screens/nutritional_plan_screen.dart index 1f8e2062..b2208223 100644 --- a/lib/screens/nutritional_plan_screen.dart +++ b/lib/screens/nutritional_plan_screen.dart @@ -126,8 +126,10 @@ class NutritionalPlanScreen extends StatelessWidget { ); break; case NutritionalPlanOptions.delete: - Provider.of(context, listen: false) - .deletePlan(nutritionalPlan.id!); + Provider.of( + context, + listen: false, + ).deletePlan(nutritionalPlan.id!); Navigator.of(context).pop(); break; } @@ -165,22 +167,22 @@ class NutritionalPlanScreen extends StatelessWidget { future: _loadFullPlan(context, nutritionalPlan.id!), builder: (context, AsyncSnapshot snapshot) => snapshot.connectionState == ConnectionState.waiting - ? SliverList( - delegate: SliverChildListDelegate( - [ - const SizedBox( - height: 200, - child: Center( - child: CircularProgressIndicator(), - ), - ), - ], + ? SliverList( + delegate: SliverChildListDelegate( + [ + const SizedBox( + height: 200, + child: Center( + child: CircularProgressIndicator(), + ), ), - ) - : Consumer( - builder: (context, value, child) => - NutritionalPlanDetailWidget(nutritionalPlan), - ), + ], + ), + ) + : Consumer( + builder: (context, value, child) => + NutritionalPlanDetailWidget(nutritionalPlan), + ), ), ], ), diff --git a/lib/widgets/add_exercise/add_exercise_multiselect_button.dart b/lib/widgets/add_exercise/add_exercise_multiselect_button.dart index 6af8a684..ae854471 100644 --- a/lib/widgets/add_exercise/add_exercise_multiselect_button.dart +++ b/lib/widgets/add_exercise/add_exercise_multiselect_button.dart @@ -33,8 +33,9 @@ class _AddExerciseMultiselectButtonState extends State MultiSelectItem(item, widget.displayName(item))).toList(), + items: widget.items + .map((item) => MultiSelectItem(item, widget.displayName(item))) + .toList(), onConfirm: (value) { setState(() { _selectedItems = value.cast(); diff --git a/lib/widgets/core/about.dart b/lib/widgets/core/about.dart index 9e430bcd..86348269 100644 --- a/lib/widgets/core/about.dart +++ b/lib/widgets/core/about.dart @@ -195,7 +195,8 @@ class AboutPage extends StatelessWidget { showLicensePage( context: context, applicationName: 'wger', - applicationVersion: 'App: ${authProvider.applicationVersion?.version ?? 'N/A'} ' + applicationVersion: + 'App: ${authProvider.applicationVersion?.version ?? 'N/A'} ' 'Server: ${authProvider.serverVersion ?? 'N/A'}', applicationLegalese: '\u{a9} ${today.year} wger contributors', applicationIcon: Padding( diff --git a/lib/widgets/dashboard/widgets/measurements.dart b/lib/widgets/dashboard/widgets/measurements.dart index 76ef69c4..ed7fbd8f 100644 --- a/lib/widgets/dashboard/widgets/measurements.dart +++ b/lib/widgets/dashboard/widgets/measurements.dart @@ -42,8 +42,9 @@ class _DashboardMeasurementWidgetState extends State Widget build(BuildContext context) { final provider = Provider.of(context, listen: false); - final items = - provider.categories.map((item) => CategoriesCard(item, elevation: 0)).toList(); + final items = provider.categories + .map((item) => CategoriesCard(item, elevation: 0)) + .toList(); if (items.isNotEmpty) { items.add( NothingFound( @@ -115,10 +116,10 @@ class _DashboardMeasurementWidgetState extends State ), decoration: BoxDecoration( shape: BoxShape.circle, - color: - Theme.of(context).textTheme.headlineSmall!.color!.withOpacity( - _current == entry.key ? 0.9 : 0.4, - ), + color: Theme.of(context).textTheme.headlineSmall!.color! + .withOpacity( + _current == entry.key ? 0.9 : 0.4, + ), ), ), ); diff --git a/lib/widgets/dashboard/widgets/nutrition.dart b/lib/widgets/dashboard/widgets/nutrition.dart index 4f7c0281..ee611ba4 100644 --- a/lib/widgets/dashboard/widgets/nutrition.dart +++ b/lib/widgets/dashboard/widgets/nutrition.dart @@ -60,8 +60,9 @@ class _DashboardNutritionWidgetState extends State { ), subtitle: Text( _hasContent - ? DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(_plan!.creationDate) + ? DateFormat.yMd( + Localizations.localeOf(context).languageCode, + ).format(_plan!.creationDate) : '', ), leading: Icon( diff --git a/lib/widgets/dashboard/widgets/routines.dart b/lib/widgets/dashboard/widgets/routines.dart index 66392c68..d5d7837e 100644 --- a/lib/widgets/dashboard/widgets/routines.dart +++ b/lib/widgets/dashboard/widgets/routines.dart @@ -175,14 +175,19 @@ class DetailContentWidget extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(s.exercise - .getTranslation( - Localizations.localeOf(context).languageCode) - .name), + Text( + s.exercise + .getTranslation( + Localizations.localeOf(context).languageCode, + ) + .name, + ), const SizedBox(width: 10), Expanded( - child: - MutedText(s.textRepr, overflow: TextOverflow.ellipsis), + child: MutedText( + s.textRepr, + overflow: TextOverflow.ellipsis, + ), ), ], ), diff --git a/lib/widgets/dashboard/widgets/weight.dart b/lib/widgets/dashboard/widgets/weight.dart index c5652cbf..dd568dc0 100644 --- a/lib/widgets/dashboard/widgets/weight.dart +++ b/lib/widgets/dashboard/widgets/weight.dart @@ -94,9 +94,12 @@ class DashboardWeightWidget extends StatelessWidget { FormScreen.routeName, arguments: FormScreenArguments( AppLocalizations.of(context).newEntry, - WeightForm(weightProvider - .getNewestEntry() - ?.copyWith(id: null, date: DateTime.now())), + WeightForm( + weightProvider.getNewestEntry()?.copyWith( + id: null, + date: DateTime.now(), + ), + ), ), ); }, diff --git a/lib/widgets/exercises/autocompleter.dart b/lib/widgets/exercises/autocompleter.dart index 133deb03..e333045a 100644 --- a/lib/widgets/exercises/autocompleter.dart +++ b/lib/widgets/exercises/autocompleter.dart @@ -85,30 +85,32 @@ class _ExerciseAutocompleterState extends State { return null; } return context.read().searchExercise( - pattern, - languageCode: Localizations.localeOf(context).languageCode, - searchEnglish: _searchEnglish, - ); + pattern, + languageCode: Localizations.localeOf(context).languageCode, + searchEnglish: _searchEnglish, + ); }, - itemBuilder: ( - BuildContext context, - Exercise exerciseSuggestion, - ) => - ListTile( - key: Key('exercise-${exerciseSuggestion.id}'), - leading: SizedBox( - width: 45, - child: ExerciseImageWidget( - image: exerciseSuggestion.getMainImage, + itemBuilder: + ( + BuildContext context, + Exercise exerciseSuggestion, + ) => ListTile( + key: Key('exercise-${exerciseSuggestion.id}'), + leading: SizedBox( + width: 45, + child: ExerciseImageWidget( + image: exerciseSuggestion.getMainImage, + ), + ), + title: Text( + exerciseSuggestion + .getTranslation(Localizations.localeOf(context).languageCode) + .name, + ), + subtitle: Text( + '${exerciseSuggestion.category!.name} / ${exerciseSuggestion.equipment.map((e) => e.name).join(', ')}', + ), ), - ), - title: Text( - exerciseSuggestion.getTranslation(Localizations.localeOf(context).languageCode).name, - ), - subtitle: Text( - '${exerciseSuggestion.category!.name} / ${exerciseSuggestion.equipment.map((e) => e.name).join(', ')}', - ), - ), emptyBuilder: (context) { return Column( mainAxisSize: MainAxisSize.min, @@ -149,7 +151,7 @@ class _ExerciseAutocompleterState extends State { }); }, dense: true, - ) + ), ], ); } diff --git a/lib/widgets/exercises/exercises.dart b/lib/widgets/exercises/exercises.dart index d5bb76a0..373515f0 100644 --- a/lib/widgets/exercises/exercises.dart +++ b/lib/widgets/exercises/exercises.dart @@ -81,21 +81,23 @@ class ExerciseDetail extends StatelessWidget { } List getVariations(BuildContext context) { - final variations = - Provider.of(context, listen: false).findExercisesByVariationId( - _exercise.variationId, - exerciseIdToExclude: _exercise.id, - ); + final variations = Provider.of(context, listen: false) + .findExercisesByVariationId( + _exercise.variationId, + exerciseIdToExclude: _exercise.id, + ); final List out = []; if (_exercise.variationId == null) { return out; } - out.add(Text( - AppLocalizations.of(context).variations, - style: Theme.of(context).textTheme.headlineSmall, - )); + out.add( + Text( + AppLocalizations.of(context).variations, + style: Theme.of(context).textTheme.headlineSmall, + ), + ); for (final element in variations) { out.add(ExerciseListTile(exercise: element)); } @@ -110,10 +112,12 @@ class ExerciseDetail extends StatelessWidget { List getNotes(BuildContext context) { final List out = []; if (_translation.notes.isNotEmpty) { - out.add(Text( - AppLocalizations.of(context).notes, - style: Theme.of(context).textTheme.headlineSmall, - )); + out.add( + Text( + AppLocalizations.of(context).notes, + style: Theme.of(context).textTheme.headlineSmall, + ), + ); for (final e in _translation.notes) { out.add(Text(e.comment)); } @@ -125,36 +129,40 @@ class ExerciseDetail extends StatelessWidget { List getMuscles(BuildContext context) { final List out = []; - out.add(Text( - AppLocalizations.of(context).muscles, - style: Theme.of(context).textTheme.headlineSmall, - )); - out.add(Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: PADDING), - child: MuscleWidget( - muscles: _exercise.muscles, - musclesSecondary: _exercise.musclesSecondary, - isFront: true, + out.add( + Text( + AppLocalizations.of(context).muscles, + style: Theme.of(context).textTheme.headlineSmall, + ), + ); + out.add( + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: PADDING), + child: MuscleWidget( + muscles: _exercise.muscles, + musclesSecondary: _exercise.musclesSecondary, + isFront: true, + ), ), ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: PADDING), - child: MuscleWidget( - muscles: _exercise.muscles, - musclesSecondary: _exercise.musclesSecondary, - isFront: false, + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: PADDING), + child: MuscleWidget( + muscles: _exercise.muscles, + musclesSecondary: _exercise.musclesSecondary, + isFront: false, + ), ), ), - ), - ], - )); + ], + ), + ); out.add( Column( @@ -183,10 +191,12 @@ class ExerciseDetail extends StatelessWidget { List getDescription(BuildContext context) { final List out = []; - out.add(Text( - AppLocalizations.of(context).description, - style: Theme.of(context).textTheme.headlineSmall, - )); + out.add( + Text( + AppLocalizations.of(context).description, + style: Theme.of(context).textTheme.headlineSmall, + ), + ); out.add(Html(data: _translation.description)); return out; @@ -195,9 +205,11 @@ class ExerciseDetail extends StatelessWidget { List getImages() { final List out = []; if (_exercise.images.isNotEmpty) { - out.add(CarouselImages( - images: _exercise.images, - )); + out.add( + CarouselImages( + images: _exercise.images, + ), + ); // out.add(ExerciseImageWidget( // image: _exercise.getMainImage, @@ -225,14 +237,16 @@ class ExerciseDetail extends StatelessWidget { ); if (_exercise.equipment.isNotEmpty) { _exercise.equipment - .map((e) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Chip( - label: Text(getTranslation(e.name, context)), - padding: EdgeInsets.zero, - backgroundColor: theme.splashColor, - ), - )) + .map( + (e) => Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Chip( + label: Text(getTranslation(e.name, context)), + padding: EdgeInsets.zero, + backgroundColor: theme.splashColor, + ), + ), + ) .forEach((element) => out.add(element)); } out.add(const SizedBox(height: PADDING)); @@ -255,11 +269,13 @@ class ExerciseDetail extends StatelessWidget { List getAliases(BuildContext context) { final List out = []; if (_translation.aliases.isNotEmpty) { - out.add(MutedText( - AppLocalizations.of(context).alsoKnownAs( - _translation.aliases.map((e) => e.alias).toList().join(', '), + out.add( + MutedText( + AppLocalizations.of(context).alsoKnownAs( + _translation.aliases.map((e) => e.alias).toList().join(', '), + ), ), - )); + ); out.add(const SizedBox(height: PADDING)); } @@ -355,9 +371,13 @@ class MuscleWidget extends StatelessWidget { children: [ SvgPicture.asset('assets/images/muscles/$background.svg'), ...muscles.map((m) => SvgPicture.asset('assets/images/muscles/main/muscle-${m.id}.svg')), - ...musclesSecondary.where((m) => !muscles.contains(m)).map((m) => SvgPicture.asset( - 'assets/images/muscles/secondary/muscle-${m.id}.svg', - )), + ...musclesSecondary + .where((m) => !muscles.contains(m)) + .map( + (m) => SvgPicture.asset( + 'assets/images/muscles/secondary/muscle-${m.id}.svg', + ), + ), ], ); } diff --git a/lib/widgets/exercises/videos.dart b/lib/widgets/exercises/videos.dart index 0a5496bf..8f38da56 100644 --- a/lib/widgets/exercises/videos.dart +++ b/lib/widgets/exercises/videos.dart @@ -68,22 +68,22 @@ class _ExerciseVideoWidgetState extends State { return hasError ? const GeneralErrorsWidget( [ - 'An error happened while loading the video. If you can, please check the application logs.' + 'An error happened while loading the video. If you can, please check the application logs.', ], ) : _controller.value.isInitialized - ? AspectRatio( - aspectRatio: _controller.value.aspectRatio, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - VideoPlayer(_controller), - _ControlsOverlay(controller: _controller), - VideoProgressIndicator(_controller, allowScrubbing: true), - ], - ), - ) - : Container(); + ? AspectRatio( + aspectRatio: _controller.value.aspectRatio, + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + VideoPlayer(_controller), + _ControlsOverlay(controller: _controller), + VideoProgressIndicator(_controller, allowScrubbing: true), + ], + ), + ) + : Container(); } } diff --git a/lib/widgets/gallery/forms.dart b/lib/widgets/gallery/forms.dart index 2c75ec30..2899ff99 100644 --- a/lib/widgets/gallery/forms.dart +++ b/lib/widgets/gallery/forms.dart @@ -197,12 +197,16 @@ class _ImageFormState extends State { _form.currentState!.save(); if (widget._image.id == null) { - Provider.of(context, listen: false) - .addImage(widget._image, _file!); + Provider.of( + context, + listen: false, + ).addImage(widget._image, _file!); Navigator.of(context).pop(); } else { - Provider.of(context, listen: false) - .editImage(widget._image, _file); + Provider.of( + context, + listen: false, + ).editImage(widget._image, _file); Navigator.of(context).pop(); } }, diff --git a/lib/widgets/measurements/charts.dart b/lib/widgets/measurements/charts.dart index 076fa493..407b1a9f 100644 --- a/lib/widgets/measurements/charts.dart +++ b/lib/widgets/measurements/charts.dart @@ -41,8 +41,10 @@ class MeasurementOverallChangeWidget extends StatelessWidget { } // ignore: prefer_interpolation_to_compose_strings - return Text(AppLocalizations.of(context).overallChangeWeight + - ' $prefix${delta.abs().toStringAsFixed(1)} $_unit'); + return Text( + AppLocalizations.of(context).overallChangeWeight + + ' $prefix${delta.abs().toStringAsFixed(1)} $_unit', + ); } } @@ -78,14 +80,16 @@ class _MeasurementChartWidgetFlState extends State { touchTooltipData: LineTouchTooltipData( getTooltipColor: (touchedSpot) => Theme.of(context).colorScheme.primaryContainer, getTooltipItems: (touchedSpots) { - final numberFormat = - NumberFormat.decimalPattern(Localizations.localeOf(context).toString()); + final numberFormat = NumberFormat.decimalPattern( + Localizations.localeOf(context).toString(), + ); return touchedSpots.map((touchedSpot) { final msSinceEpoch = touchedSpot.x.toInt(); final DateTime date = DateTime.fromMillisecondsSinceEpoch(touchedSpot.x.toInt()); - final dateStr = - DateFormat.Md(Localizations.localeOf(context).languageCode).format(date); + final dateStr = DateFormat.Md( + Localizations.localeOf(context).languageCode, + ).format(date); // Check if this is an interpolated point (milliseconds ending with 123) final bool isInterpolated = msSinceEpoch % 1000 == INTERPOLATION_MARKER; @@ -180,10 +184,12 @@ class _MeasurementChartWidgetFlState extends State { lineBarsData: [ LineChartBarData( spots: widget._entries - .map((e) => FlSpot( - e.date.millisecondsSinceEpoch.toDouble(), - e.value.toDouble(), - )) + .map( + (e) => FlSpot( + e.date.millisecondsSinceEpoch.toDouble(), + e.value.toDouble(), + ), + ) .toList(), isCurved: false, color: Theme.of(context).colorScheme.primary, @@ -194,10 +200,12 @@ class _MeasurementChartWidgetFlState extends State { if (widget.avgs != null) LineChartBarData( spots: widget.avgs! - .map((e) => FlSpot( - e.date.millisecondsSinceEpoch.toDouble(), - e.value.toDouble(), - )) + .map( + (e) => FlSpot( + e.date.millisecondsSinceEpoch.toDouble(), + e.value.toDouble(), + ), + ) .toList(), isCurved: false, color: Theme.of(context).colorScheme.tertiary, diff --git a/lib/widgets/measurements/entries.dart b/lib/widgets/measurements/entries.dart index 78460004..6573375f 100644 --- a/lib/widgets/measurements/entries.dart +++ b/lib/widgets/measurements/entries.dart @@ -40,81 +40,85 @@ class EntriesList extends StatelessWidget { final numberFormat = NumberFormat.decimalPattern(Localizations.localeOf(context).toString()); final provider = Provider.of(context, listen: false); - final entriesAll = - _category.entries.map((e) => MeasurementChartEntry(e.value, e.date)).toList(); + final entriesAll = _category.entries + .map((e) => MeasurementChartEntry(e.value, e.date)) + .toList(); final entries7dAvg = moving7dAverage(entriesAll); - return Column(children: [ - ...getOverviewWidgetsSeries( - _category.name, - entriesAll, - entries7dAvg, - plans, - _category.unit, - context, - ), - SizedBox( - height: 300, - child: ListView.builder( - padding: const EdgeInsets.all(10.0), - itemCount: _category.entries.length, - itemBuilder: (context, index) { - final currentEntry = _category.entries[index]; + return Column( + children: [ + ...getOverviewWidgetsSeries( + _category.name, + entriesAll, + entries7dAvg, + plans, + _category.unit, + context, + ), + SizedBox( + height: 300, + child: ListView.builder( + padding: const EdgeInsets.all(10.0), + itemCount: _category.entries.length, + itemBuilder: (context, index) { + final currentEntry = _category.entries[index]; - return Card( - child: ListTile( - title: Text('${numberFormat.format(currentEntry.value)} ${_category.unit}'), - subtitle: Text( - DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(currentEntry.date), - ), - trailing: PopupMenuButton( - itemBuilder: (BuildContext context) { - return [ - PopupMenuItem( - child: Text(AppLocalizations.of(context).edit), - onTap: () => Navigator.pushNamed( - context, - FormScreen.routeName, - arguments: FormScreenArguments( - AppLocalizations.of(context).edit, - MeasurementEntryForm( - currentEntry.category, - currentEntry, + return Card( + child: ListTile( + title: Text('${numberFormat.format(currentEntry.value)} ${_category.unit}'), + subtitle: Text( + DateFormat.yMd( + Localizations.localeOf(context).languageCode, + ).format(currentEntry.date), + ), + trailing: PopupMenuButton( + itemBuilder: (BuildContext context) { + return [ + PopupMenuItem( + child: Text(AppLocalizations.of(context).edit), + onTap: () => Navigator.pushNamed( + context, + FormScreen.routeName, + arguments: FormScreenArguments( + AppLocalizations.of(context).edit, + MeasurementEntryForm( + currentEntry.category, + currentEntry, + ), ), ), ), - ), - PopupMenuItem( - child: Text(AppLocalizations.of(context).delete), - onTap: () async { - // Delete entry from DB - await provider.deleteEntry( - currentEntry.id!, - currentEntry.category, - ); - - // and inform the user - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - AppLocalizations.of(context).successfullyDeleted, - textAlign: TextAlign.center, - ), - ), + PopupMenuItem( + child: Text(AppLocalizations.of(context).delete), + onTap: () async { + // Delete entry from DB + await provider.deleteEntry( + currentEntry.id!, + currentEntry.category, ); - } - }, - ), - ]; - }, + + // and inform the user + if (context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + AppLocalizations.of(context).successfullyDeleted, + textAlign: TextAlign.center, + ), + ), + ); + } + }, + ), + ]; + }, + ), ), - ), - ); - }, + ); + }, + ), ), - ), - ]); + ], + ); } } diff --git a/lib/widgets/measurements/forms.dart b/lib/widgets/measurements/forms.dart index e547dc2d..41a2ea09 100644 --- a/lib/widgets/measurements/forms.dart +++ b/lib/widgets/measurements/forms.dart @@ -284,13 +284,15 @@ class MeasurementEntryForm extends StatelessWidget { ? await Provider.of( context, listen: false, - ).addEntry(MeasurementEntry( - id: _entryData['id'], - category: _entryData['category'], - date: _entryData['date'], - value: _entryData['value'], - notes: _entryData['notes'], - )) + ).addEntry( + MeasurementEntry( + id: _entryData['id'], + category: _entryData['category'], + date: _entryData['date'], + value: _entryData['value'], + notes: _entryData['notes'], + ), + ) : await Provider.of( context, listen: false, diff --git a/lib/widgets/measurements/helpers.dart b/lib/widgets/measurements/helpers.dart index 4a6f05af..00369b06 100644 --- a/lib/widgets/measurements/helpers.dart +++ b/lib/widgets/measurements/helpers.dart @@ -25,8 +25,8 @@ List getOverviewWidgets( child: Text( 'No data available', style: Theme.of(context).textTheme.bodyLarge?.copyWith( - color: Theme.of(context).colorScheme.secondary.withValues(alpha: 0.7), - ), + color: Theme.of(context).colorScheme.secondary.withValues(alpha: 0.7), + ), ), ) : MeasurementChartWidgetFl(raw, unit, avgs: avg), diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart index c8a4b3f2..13e9ca18 100644 --- a/lib/widgets/nutrition/charts.dart +++ b/lib/widgets/nutrition/charts.dart @@ -71,17 +71,21 @@ class FlNutritionalPlanGoalWidget extends StatelessWidget { // paint a surplus if (val > plan) { - return Stack(children: [ - segment(normWidth * val / plan, COLOR_SURPLUS), - segment(normWidth, LIST_OF_COLORS8[0]), - ]); + return Stack( + children: [ + segment(normWidth * val / plan, COLOR_SURPLUS), + segment(normWidth, LIST_OF_COLORS8[0]), + ], + ); } // paint a deficit - return Stack(children: [ - segment(normWidth, Theme.of(context).colorScheme.surface), - segment(normWidth * val / plan, LIST_OF_COLORS8[0]), - ]); + return Stack( + children: [ + segment(normWidth, Theme.of(context).colorScheme.surface), + segment(normWidth * val / plan, LIST_OF_COLORS8[0]), + ], + ); } @override @@ -90,87 +94,102 @@ class FlNutritionalPlanGoalWidget extends StatelessWidget { final goals = plan.nutritionalGoals; final today = plan.loggedNutritionalValuesToday; - return LayoutBuilder(builder: (context, constraints) { - // if any of the bars goes over 100%, find the one that goes over the most - // that one needs the most horizontal space to show how much it goes over, - // and therefore reduces the width of "100%" the most, and this width we want - // to be consistent for all other bars. - // if none goes over, 100% means fill all available space - final maxVal = [ - 1.0, - if (goals.energy != null && goals.energy! > 0) today.energy / goals.energy!, - if (goals.protein != null && goals.protein! > 0) today.protein / goals.protein!, - if (goals.carbohydrates != null && goals.carbohydrates! > 0) - today.carbohydrates / goals.carbohydrates!, - if (goals.fat != null && goals.fat! > 0) today.fat / goals.fat!, - if (goals.fiber != null && goals.fiber! > 0) today.fiber / goals.fiber!, - ].reduce(max); + return LayoutBuilder( + builder: (context, constraints) { + // if any of the bars goes over 100%, find the one that goes over the most + // that one needs the most horizontal space to show how much it goes over, + // and therefore reduces the width of "100%" the most, and this width we want + // to be consistent for all other bars. + // if none goes over, 100% means fill all available space + final maxVal = [ + 1.0, + if (goals.energy != null && goals.energy! > 0) today.energy / goals.energy!, + if (goals.protein != null && goals.protein! > 0) today.protein / goals.protein!, + if (goals.carbohydrates != null && goals.carbohydrates! > 0) + today.carbohydrates / goals.carbohydrates!, + if (goals.fat != null && goals.fat! > 0) today.fat / goals.fat!, + if (goals.fiber != null && goals.fiber! > 0) today.fiber / goals.fiber!, + ].reduce(max); - final normWidth = constraints.maxWidth / maxVal; + final normWidth = constraints.maxWidth / maxVal; - String fmtMacro(String name, double today, double? goal, String unit) { - return '$name: ${today.toStringAsFixed(0)}${goal == null ? '' : ' / ${goal.toStringAsFixed(0)}'} $unit'; - } + String fmtMacro(String name, double today, double? goal, String unit) { + return '$name: ${today.toStringAsFixed(0)}${goal == null ? '' : ' / ${goal.toStringAsFixed(0)}'} $unit'; + } - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(fmtMacro( - AppLocalizations.of(context).energy, - today.energy, - goals.energy, - AppLocalizations.of(context).kcal, - )), - const SizedBox(height: 2), - _diyGauge(context, normWidth, goals.energy, today.energy), - const SizedBox(height: 8), - Text(fmtMacro( - AppLocalizations.of(context).protein, - today.protein, - goals.protein, - AppLocalizations.of(context).g, - )), - const SizedBox(height: 2), - _diyGauge(context, normWidth, goals.protein, today.protein), - const SizedBox(height: 8), - Text(fmtMacro( - AppLocalizations.of(context).carbohydrates, - today.carbohydrates, - goals.carbohydrates, - AppLocalizations.of(context).g, - )), - const SizedBox(height: 2), - _diyGauge( - context, - normWidth, - goals.carbohydrates, - today.carbohydrates, - ), - const SizedBox(height: 8), - Text(fmtMacro( - AppLocalizations.of(context).fat, - today.fat, - goals.fat, - AppLocalizations.of(context).g, - )), - const SizedBox(height: 2), - _diyGauge(context, normWidth, goals.fat, today.fat), - // optionally display the advanced macro goals: - if (goals.fiber != null) - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 8), - Text(fmtMacro( - AppLocalizations.of(context).fiber, - today.fiber, - goals.fiber, + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + fmtMacro( + AppLocalizations.of(context).energy, + today.energy, + goals.energy, + AppLocalizations.of(context).kcal, + ), + ), + const SizedBox(height: 2), + _diyGauge(context, normWidth, goals.energy, today.energy), + const SizedBox(height: 8), + Text( + fmtMacro( + AppLocalizations.of(context).protein, + today.protein, + goals.protein, AppLocalizations.of(context).g, - )), - const SizedBox(height: 2), - _diyGauge(context, normWidth, goals.fiber, today.fiber), - ]), - ], - ); - }); + ), + ), + const SizedBox(height: 2), + _diyGauge(context, normWidth, goals.protein, today.protein), + const SizedBox(height: 8), + Text( + fmtMacro( + AppLocalizations.of(context).carbohydrates, + today.carbohydrates, + goals.carbohydrates, + AppLocalizations.of(context).g, + ), + ), + const SizedBox(height: 2), + _diyGauge( + context, + normWidth, + goals.carbohydrates, + today.carbohydrates, + ), + const SizedBox(height: 8), + Text( + fmtMacro( + AppLocalizations.of(context).fat, + today.fat, + goals.fat, + AppLocalizations.of(context).g, + ), + ), + const SizedBox(height: 2), + _diyGauge(context, normWidth, goals.fat, today.fat), + // optionally display the advanced macro goals: + if (goals.fiber != null) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 8), + Text( + fmtMacro( + AppLocalizations.of(context).fiber, + today.fiber, + goals.fiber, + AppLocalizations.of(context).g, + ), + ), + const SizedBox(height: 2), + _diyGauge(context, normWidth, goals.fiber, today.fiber), + ], + ), + ], + ); + }, + ); } } @@ -227,16 +246,19 @@ class FlNutritionalPlanPieChartState extends State Padding( - padding: const EdgeInsets.symmetric(vertical: 2), - child: Indicator(color: e.$2, text: e.$1, isSquare: true), - )) - .toList(), + children: + [ + (AppLocalizations.of(context).protein, LIST_OF_COLORS3[1]), + (AppLocalizations.of(context).carbohydrates, LIST_OF_COLORS3[0]), + (AppLocalizations.of(context).fat, LIST_OF_COLORS3[2]), + ] + .map( + (e) => Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Indicator(color: e.$2, text: e.$1, isSquare: true), + ), + ) + .toList(), ), const SizedBox(width: 28), ], @@ -433,21 +455,22 @@ class NutritionalDiaryChartWidgetFlState extends State Indicator( - text: e.$1, - color: e.$2, - isSquare: true, - marginRight: 0, - ), - ) - .toList(), + children: + [ + (AppLocalizations.of(context).deficit, colorPlanned), + (AppLocalizations.of(context).surplus, COLOR_SURPLUS), + (AppLocalizations.of(context).today, colorLoggedToday), + (AppLocalizations.of(context).weekAverage, colorLogged7Day), + ] + .map( + (e) => Indicator( + text: e.$1, + color: e.$2, + isSquare: true, + marginRight: 0, + ), + ) + .toList(), ), ), ], @@ -463,8 +486,8 @@ class MealDiaryBarChartWidget extends StatefulWidget { super.key, required NutritionalValues logged, required NutritionalValues planned, - }) : _logged = logged, - _planned = planned; + }) : _logged = logged, + _planned = planned; final NutritionalValues _logged; final NutritionalValues _planned; @@ -489,12 +512,12 @@ class MealDiaryBarChartWidgetState extends State { } Widget leftTitles(double value, TitleMeta meta) => SideTitleWidget( - meta: meta, - child: Text( - AppLocalizations.of(context).percentValue(value.toStringAsFixed(0)), - style: const TextStyle(fontSize: 10), - ), - ); + meta: meta, + child: Text( + AppLocalizations.of(context).percentValue(value.toStringAsFixed(0)), + style: const TextStyle(fontSize: 10), + ), + ); @override Widget build(BuildContext context) { diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index ad31917e..3d7daaa3 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -138,8 +138,10 @@ Widget getIngredientLogForm(NutritionalPlan plan) { return IngredientForm( recent: plan.dedupDiaryEntries, onSave: (BuildContext context, MealItem mealItem, DateTime? dt) { - Provider.of(context, listen: false) - .logIngredientToDiary(mealItem, plan.id!, dt); + Provider.of( + context, + listen: false, + ).logIngredientToDiary(mealItem, plan.id!, dt); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( @@ -236,8 +238,9 @@ class IngredientFormState extends State { Widget build(BuildContext context) { final String unit = AppLocalizations.of(context).g; final queryLower = _searchQuery.toLowerCase(); - final suggestions = - widget.recent.where((e) => e.ingredient.name.toLowerCase().contains(queryLower)).toList(); + final suggestions = widget.recent + .where((e) => e.ingredient.name.toLowerCase().contains(queryLower)) + .toList(); final numberFormat = NumberFormat.decimalPattern(Localizations.localeOf(context).toString()); return Container( @@ -359,31 +362,32 @@ class IngredientFormState extends State { context, listen: false, ).fetchIngredient(_mealItem.ingredientId), - builder: ( - BuildContext context, - AsyncSnapshot snapshot, - ) { - if (snapshot.hasData) { - _mealItem.ingredient = snapshot.data!; - return MealItemValuesTile( - ingredient: _mealItem.ingredient, - nutritionalValues: _mealItem.nutritionalValues, - ); - } else if (snapshot.hasError) { - return Padding( - padding: const EdgeInsets.only(top: 16), - child: Text( - 'Ingredient lookup error: ${snapshot.error}', - style: const TextStyle(color: Colors.red), - ), - ); - } - return const SizedBox( - width: 20, - height: 20, - child: CircularProgressIndicator(), - ); - }, + builder: + ( + BuildContext context, + AsyncSnapshot snapshot, + ) { + if (snapshot.hasData) { + _mealItem.ingredient = snapshot.data!; + return MealItemValuesTile( + ingredient: _mealItem.ingredient, + nutritionalValues: _mealItem.nutritionalValues, + ); + } else if (snapshot.hasError) { + return Padding( + padding: const EdgeInsets.only(top: 16), + child: Text( + 'Ingredient lookup error: ${snapshot.error}', + style: const TextStyle(color: Colors.red), + ), + ); + } + return const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(), + ); + }, ), ], ), @@ -432,10 +436,12 @@ class IngredientFormState extends State { title: Text( '${suggestions[index].ingredient.name} (${suggestions[index].amount.toStringAsFixed(0)}$unit)', ), - subtitle: Text(getShortNutritionValues( - suggestions[index].ingredient.nutritionalValues, - context, - )), + subtitle: Text( + getShortNutritionValues( + suggestions[index].ingredient.nutritionalValues, + context, + ), + ), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/widgets/nutrition/helpers.dart b/lib/widgets/nutrition/helpers.dart index 1dc2ea67..95cd543a 100644 --- a/lib/widgets/nutrition/helpers.dart +++ b/lib/widgets/nutrition/helpers.dart @@ -27,18 +27,18 @@ import 'package:wger/widgets/core/core.dart'; import 'package:wger/widgets/nutrition/ingredient_dialogs.dart'; List getNutritionColumnNames(BuildContext context) => [ - AppLocalizations.of(context).energy, - AppLocalizations.of(context).protein, - AppLocalizations.of(context).carbohydrates, - AppLocalizations.of(context).fat, - ]; + AppLocalizations.of(context).energy, + AppLocalizations.of(context).protein, + AppLocalizations.of(context).carbohydrates, + AppLocalizations.of(context).fat, +]; List getNutritionalValues(NutritionalValues values, BuildContext context) => [ - AppLocalizations.of(context).kcalValue(values.energy.toStringAsFixed(0)), - AppLocalizations.of(context).gValue(values.protein.toStringAsFixed(0)), - AppLocalizations.of(context).gValue(values.carbohydrates.toStringAsFixed(0)), - AppLocalizations.of(context).gValue(values.fat.toStringAsFixed(0)), - ]; + AppLocalizations.of(context).kcalValue(values.energy.toStringAsFixed(0)), + AppLocalizations.of(context).gValue(values.protein.toStringAsFixed(0)), + AppLocalizations.of(context).gValue(values.carbohydrates.toStringAsFixed(0)), + AppLocalizations.of(context).gValue(values.fat.toStringAsFixed(0)), +]; List getNutritionColumnFlexes(BuildContext context) { return getNutritionColumnNames(context).map((e) { @@ -51,11 +51,13 @@ List getNutritionColumnFlexes(BuildContext context) { } List muted(List children) => children - .map((e) => MutedText( - e, - textAlign: TextAlign.right, - overflow: TextOverflow.ellipsis, - )) + .map( + (e) => MutedText( + e, + textAlign: TextAlign.right, + overflow: TextOverflow.ellipsis, + ), + ) .toList(); // return a row of elements in the standard macros spacing @@ -85,15 +87,17 @@ String getShortNutritionValues(NutritionalValues values, BuildContext context) { } String getKcalConsumed(Meal meal, BuildContext context) { - final consumed = - meal.diaryEntriesToday.map((e) => e.nutritionalValues.energy).fold(0.0, (a, b) => a + b); + final consumed = meal.diaryEntriesToday + .map((e) => e.nutritionalValues.energy) + .fold(0.0, (a, b) => a + b); return AppLocalizations.of(context).kcalValue(consumed.toStringAsFixed(0)); } String getKcalConsumedVsPlanned(Meal meal, BuildContext context) { final planned = meal.plannedNutritionalValues.energy; - final consumed = - meal.diaryEntriesToday.map((e) => e.nutritionalValues.energy).fold(0.0, (a, b) => a + b); + final consumed = meal.diaryEntriesToday + .map((e) => e.nutritionalValues.energy) + .fold(0.0, (a, b) => a + b); final loc = AppLocalizations.of(context); return '${consumed.toStringAsFixed(0)} / ${planned.toStringAsFixed(0)} ${loc.kcal}'; diff --git a/lib/widgets/nutrition/ingredient_dialogs.dart b/lib/widgets/nutrition/ingredient_dialogs.dart index 449c08e3..b918b360 100644 --- a/lib/widgets/nutrition/ingredient_dialogs.dart +++ b/lib/widgets/nutrition/ingredient_dialogs.dart @@ -61,7 +61,7 @@ Widget ingredientImage(String url, BuildContext context) { ), ), ), - ) + ), ], ), ), @@ -201,8 +201,9 @@ class IngredientScanResultDialog extends StatelessWidget { if (ingredient != null) Padding( padding: const EdgeInsets.only(bottom: 8.0), - child: - Text(AppLocalizations.of(context).productFoundDescription(ingredient.name)), + child: Text( + AppLocalizations.of(context).productFoundDescription(ingredient.name), + ), ), if (ingredient?.image?.url != null) ingredientImage(ingredient!.image!.url, context), if (snapshot.connectionState != ConnectionState.done && !snapshot.hasError) diff --git a/lib/widgets/nutrition/macro_nutrients_table.dart b/lib/widgets/nutrition/macro_nutrients_table.dart index 088edaee..7a1bfc62 100644 --- a/lib/widgets/nutrition/macro_nutrients_table.dart +++ b/lib/widgets/nutrition/macro_nutrients_table.dart @@ -22,13 +22,13 @@ class MacronutrientsTable extends StatelessWidget { final loc = AppLocalizations.of(context); Widget columnHeader(bool left, String title) => Padding( - padding: const EdgeInsets.symmetric(vertical: tablePadding), - child: Text( - title, - style: const TextStyle(fontWeight: FontWeight.bold), - textAlign: left ? TextAlign.left : TextAlign.right, - ), - ); + padding: const EdgeInsets.symmetric(vertical: tablePadding), + child: Text( + title, + style: const TextStyle(fontWeight: FontWeight.bold), + textAlign: left ? TextAlign.left : TextAlign.right, + ), + ); TableRow macroRow(int indent, bool g, String title, double? Function(NutritionalGoals ng) get) { final goal = get(nutritionalGoals); diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index 3aebb160..4ba99cf6 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -36,7 +36,7 @@ import 'package:wger/widgets/nutrition/widgets.dart'; enum viewMode { base, // just highlevel meal info (name, time) withIngredients, // + ingredients - withAllDetails // + nutritional breakdown of ingredients, + logged today + withAllDetails, // + nutritional breakdown of ingredients, + logged today } class MealWidget extends StatefulWidget { @@ -173,8 +173,9 @@ class _MealWidgetState extends State { ), ) else - ...widget._meal.mealItems - .map((item) => MealItemEditableFullTile(item, _viewMode, _editing)), + ...widget._meal.mealItems.map( + (item) => MealItemEditableFullTile(item, _viewMode, _editing), + ), if (_viewMode == viewMode.withIngredients || _viewMode == viewMode.withAllDetails) const Divider(), if (_viewMode == viewMode.withIngredients || _viewMode == viewMode.withAllDetails) @@ -201,12 +202,14 @@ class _MealWidgetState extends State { planned: widget._meal.plannedNutritionalValues, logged: widget._meal.loggedNutritionalValuesToday, ), - ...widget._meal.diaryEntriesToday.map((item) => Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [DiaryEntryTile(diaryEntry: item)], - ), - )), + ...widget._meal.diaryEntriesToday.map( + (item) => Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [DiaryEntryTile(diaryEntry: item)], + ), + ), + ), ], ), ], @@ -288,11 +291,11 @@ class MealHeader extends StatelessWidget { required viewMode viewMode, required Function() toggleEditing, required Function() toggleViewMode, - }) : _meal = meal, - _editing = editing, - _viewMode = viewMode, - _toggleViewMode = toggleViewMode, - _toggleEditing = toggleEditing; + }) : _meal = meal, + _editing = editing, + _viewMode = viewMode, + _toggleViewMode = toggleViewMode, + _toggleEditing = toggleEditing; @override Widget build(BuildContext context) { diff --git a/lib/widgets/nutrition/nutrition_tiles.dart b/lib/widgets/nutrition/nutrition_tiles.dart index ae089399..36f20155 100644 --- a/lib/widgets/nutrition/nutrition_tiles.dart +++ b/lib/widgets/nutrition/nutrition_tiles.dart @@ -82,8 +82,10 @@ class DiaryEntryTile extends StatelessWidget { : IconButton( tooltip: AppLocalizations.of(context).delete, onPressed: () { - Provider.of(context, listen: false) - .deleteLog(diaryEntry.id!, nutritionalPlan!.id!); + Provider.of( + context, + listen: false, + ).deleteLog(diaryEntry.id!, nutritionalPlan!.id!); }, icon: const Icon(Icons.delete_outline), iconSize: ICON_SIZE_SMALL, diff --git a/lib/widgets/nutrition/nutritional_diary_detail.dart b/lib/widgets/nutrition/nutritional_diary_detail.dart index d6c90038..3da5beaf 100644 --- a/lib/widgets/nutrition/nutritional_diary_detail.dart +++ b/lib/widgets/nutrition/nutritional_diary_detail.dart @@ -85,13 +85,13 @@ class NutritionDiaryTable extends StatelessWidget { final loc = AppLocalizations.of(context); Widget columnHeader(bool left, String title) => Padding( - padding: const EdgeInsets.symmetric(vertical: tablePadding), - child: Text( - title, - style: const TextStyle(fontWeight: FontWeight.bold), - textAlign: left ? TextAlign.left : TextAlign.right, - ), - ); + padding: const EdgeInsets.symmetric(vertical: tablePadding), + child: Text( + title, + style: const TextStyle(fontWeight: FontWeight.bold), + textAlign: left ? TextAlign.left : TextAlign.right, + ), + ); TableRow macroRow(int indent, bool g, String title, double Function(NutritionalValues nv) get) { final valFn = g ? loc.gValue : loc.kcalValue; @@ -115,12 +115,14 @@ class NutritionDiaryTable extends StatelessWidget { ), columnWidths: const {0: FractionColumnWidth(0.4)}, children: [ - TableRow(children: [ - columnHeader(true, loc.macronutrients), - columnHeader(false, loc.planned), - columnHeader(false, loc.logged), - columnHeader(false, loc.difference), - ]), + TableRow( + children: [ + columnHeader(true, loc.macronutrients), + columnHeader(false, loc.planned), + columnHeader(false, loc.logged), + columnHeader(false, loc.difference), + ], + ), macroRow(0, false, loc.energy, (NutritionalValues nv) => nv.energy), macroRow(0, true, loc.protein, (NutritionalValues nv) => nv.protein), macroRow(0, true, loc.carbohydrates, (NutritionalValues nv) => nv.carbohydrates), diff --git a/lib/widgets/nutrition/nutritional_diary_table.dart b/lib/widgets/nutrition/nutritional_diary_table.dart index bbe296a8..d00a6f2f 100644 --- a/lib/widgets/nutrition/nutritional_diary_table.dart +++ b/lib/widgets/nutrition/nutritional_diary_table.dart @@ -82,41 +82,44 @@ class NutritionalDiaryTable extends StatelessWidget { decoration: BoxDecoration( border: Border(top: BorderSide(color: Colors.grey[300]!)), ), - children: [ - Text( - style: Theme.of(context).textTheme.titleMedium?.copyWith(color: LIST_OF_COLORS3.first), - DateFormat.Md(Localizations.localeOf(context).languageCode).format(date), - ), - Text( - textAlign: TextAlign.end, - values.energy.toStringAsFixed(0), - ), - if (goals.energy != null) - Text( - textAlign: TextAlign.end, - (values.energy - goals.energy!).toStringAsFixed(0), - ), - Text( - textAlign: TextAlign.end, - values.protein.toStringAsFixed(0), - ), - Text( - textAlign: TextAlign.end, - values.carbohydrates.toStringAsFixed(0), - ), - Text( - textAlign: TextAlign.end, - values.fat.toStringAsFixed(0), - ), - ].map((element) { - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - NutritionalDiaryScreen.routeName, - arguments: NutritionalDiaryArguments(plan, date), - ), - child: element, - ); - }).toList(), + children: + [ + Text( + style: Theme.of( + context, + ).textTheme.titleMedium?.copyWith(color: LIST_OF_COLORS3.first), + DateFormat.Md(Localizations.localeOf(context).languageCode).format(date), + ), + Text( + textAlign: TextAlign.end, + values.energy.toStringAsFixed(0), + ), + if (goals.energy != null) + Text( + textAlign: TextAlign.end, + (values.energy - goals.energy!).toStringAsFixed(0), + ), + Text( + textAlign: TextAlign.end, + values.protein.toStringAsFixed(0), + ), + Text( + textAlign: TextAlign.end, + values.carbohydrates.toStringAsFixed(0), + ), + Text( + textAlign: TextAlign.end, + values.fat.toStringAsFixed(0), + ), + ].map((element) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + NutritionalDiaryScreen.routeName, + arguments: NutritionalDiaryArguments(plan, date), + ), + child: element, + ); + }).toList(), ); } } diff --git a/lib/widgets/nutrition/nutritional_plan_detail.dart b/lib/widgets/nutrition/nutritional_plan_detail.dart index b202a30b..5159909b 100644 --- a/lib/widgets/nutrition/nutritional_plan_detail.dart +++ b/lib/widgets/nutrition/nutritional_plan_detail.dart @@ -35,10 +35,13 @@ class NutritionalPlanDetailWidget extends StatelessWidget { @override Widget build(BuildContext context) { final nutritionalGoals = _nutritionalPlan.nutritionalGoals; - final lastWeightEntry = - Provider.of(context, listen: false).getNewestEntry(); - final nutritionalGoalsGperKg = - lastWeightEntry != null ? nutritionalGoals / lastWeightEntry.weight.toDouble() : null; + final lastWeightEntry = Provider.of( + context, + listen: false, + ).getNewestEntry(); + final nutritionalGoalsGperKg = lastWeightEntry != null + ? nutritionalGoals / lastWeightEntry.weight.toDouble() + : null; return SliverList( delegate: SliverChildListDelegate( @@ -57,8 +60,8 @@ class NutritionalPlanDetailWidget extends StatelessWidget { Localizations.localeOf(context).languageCode, ).format(_nutritionalPlan.startDate)} (${AppLocalizations.of(context).openEnded})', style: Theme.of(context).textTheme.titleSmall?.copyWith( - fontStyle: FontStyle.italic, - ), + fontStyle: FontStyle.italic, + ), textAlign: TextAlign.center, ), ), @@ -73,12 +76,14 @@ class NutritionalPlanDetailWidget extends StatelessWidget { ), ), const SizedBox(height: 10), - ..._nutritionalPlan.meals.map((meal) => MealWidget( - meal, - _nutritionalPlan.dedupMealItems, - false, - false, - )), + ..._nutritionalPlan.meals.map( + (meal) => MealWidget( + meal, + _nutritionalPlan.dedupMealItems, + false, + false, + ), + ), MealWidget( _nutritionalPlan.pseudoMealOthers('Other logs'), _nutritionalPlan.dedupMealItems, diff --git a/lib/widgets/nutrition/nutritional_plans_list.dart b/lib/widgets/nutrition/nutritional_plans_list.dart index 9f45149d..3c9d0e95 100644 --- a/lib/widgets/nutrition/nutritional_plans_list.dart +++ b/lib/widgets/nutrition/nutritional_plans_list.dart @@ -77,9 +77,9 @@ class NutritionalPlansList extends StatelessWidget { Text( weightChangeText, style: Theme.of(context).textTheme.bodySmall?.copyWith( - fontWeight: FontWeight.bold, - color: weightChangeColor, - ), + fontWeight: FontWeight.bold, + color: weightChangeColor, + ), ), ], ), @@ -123,60 +123,64 @@ class NutritionalPlansList extends StatelessWidget { _buildWeightChangeInfo(context, currentPlan.startDate, currentPlan.endDate), ], ), - trailing: Row(mainAxisSize: MainAxisSize.min, children: [ - const VerticalDivider(), - IconButton( - icon: const Icon(Icons.delete), - tooltip: AppLocalizations.of(context).delete, - onPressed: () async { - // Delete the plan from DB - await showDialog( - context: context, - builder: (BuildContext contextDialog) { - return AlertDialog( - content: Text( - AppLocalizations.of(context) - .confirmDelete(currentPlan.description), - ), - actions: [ - TextButton( - child: Text( - MaterialLocalizations.of(context).cancelButtonLabel, - ), - onPressed: () => Navigator.of(contextDialog).pop(), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const VerticalDivider(), + IconButton( + icon: const Icon(Icons.delete), + tooltip: AppLocalizations.of(context).delete, + onPressed: () async { + // Delete the plan from DB + await showDialog( + context: context, + builder: (BuildContext contextDialog) { + return AlertDialog( + content: Text( + AppLocalizations.of( + context, + ).confirmDelete(currentPlan.description), ), - TextButton( - child: Text( - AppLocalizations.of(context).delete, - style: TextStyle( - color: Theme.of(context).colorScheme.error, + actions: [ + TextButton( + child: Text( + MaterialLocalizations.of(context).cancelButtonLabel, ), + onPressed: () => Navigator.of(contextDialog).pop(), ), - onPressed: () { - // Confirmed, delete the plan - _nutritionProvider.deletePlan(currentPlan.id!); - - // Close the popup - Navigator.of(contextDialog).pop(); - - // and inform the user - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - AppLocalizations.of(context).successfullyDeleted, - textAlign: TextAlign.center, - ), + TextButton( + child: Text( + AppLocalizations.of(context).delete, + style: TextStyle( + color: Theme.of(context).colorScheme.error, ), - ); - }, - ), - ], - ); - }, - ); - }, - ), - ]), + ), + onPressed: () { + // Confirmed, delete the plan + _nutritionProvider.deletePlan(currentPlan.id!); + + // Close the popup + Navigator.of(contextDialog).pop(); + + // and inform the user + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + AppLocalizations.of(context).successfullyDeleted, + textAlign: TextAlign.center, + ), + ), + ); + }, + ), + ], + ); + }, + ); + }, + ), + ], + ), ), ); }, diff --git a/lib/widgets/nutrition/widgets.dart b/lib/widgets/nutrition/widgets.dart index 8b7a95ff..c44b2bd3 100644 --- a/lib/widgets/nutrition/widgets.dart +++ b/lib/widgets/nutrition/widgets.dart @@ -38,19 +38,19 @@ class ScanReader extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - body: ReaderWidget( - onScan: (result) { - // notes: - // 1. even if result.isValid, result.error is always non-null (and set to "") - // 2. i've never encountered scan errors to see when they occur, and - // i wouldn't know what to do about them anyway, so we simply return - // result.text in such case (which presumably will be null, or "") - // 3. when user cancels (swipe left / back button) this code is no longer - // run and the caller receives null - Navigator.pop(context, result.text); - }, - ), - ); + body: ReaderWidget( + onScan: (result) { + // notes: + // 1. even if result.isValid, result.error is always non-null (and set to "") + // 2. i've never encountered scan errors to see when they occur, and + // i wouldn't know what to do about them anyway, so we simply return + // result.text in such case (which presumably will be null, or "") + // 3. when user cancels (swipe left / back button) this code is no longer + // run and the caller receives null + Navigator.pop(context, result.text); + }, + ), + ); } class IngredientTypeahead extends StatefulWidget { @@ -94,8 +94,9 @@ class _IngredientTypeaheadState extends State { Future openBarcodeScan(BuildContext context) async { try { - final code = await Navigator.of(context) - .push(MaterialPageRoute(builder: (context) => const ScanReader())); + final code = await Navigator.of( + context, + ).push(MaterialPageRoute(builder: (context) => const ScanReader())); if (code == null) { return ''; @@ -217,8 +218,10 @@ class _IngredientTypeaheadState extends State { showDialog( context: context, builder: (context) => FutureBuilder( - future: Provider.of(context, listen: false) - .searchIngredientWithBarcode(barcode), + future: Provider.of( + context, + listen: false, + ).searchIngredientWithBarcode(barcode), builder: (BuildContext context, AsyncSnapshot snapshot) { return IngredientScanResultDialog(snapshot, barcode, widget.selectIngredient); }, diff --git a/lib/widgets/routines/day.dart b/lib/widgets/routines/day.dart index 46bc5e3c..bcd3e4a8 100644 --- a/lib/widgets/routines/day.dart +++ b/lib/widgets/routines/day.dart @@ -128,9 +128,9 @@ class DayHeader extends StatelessWidget { final bool _viewMode; const DayHeader({required DayData day, required int routineId, bool viewMode = false}) - : _dayData = day, - _viewMode = viewMode, - _routineId = routineId; + : _dayData = day, + _viewMode = viewMode, + _routineId = routineId; @override Widget build(BuildContext context) { diff --git a/lib/widgets/routines/forms/day.dart b/lib/widgets/routines/forms/day.dart index d5a6fc38..0cafbdaa 100644 --- a/lib/widgets/routines/forms/day.dart +++ b/lib/widgets/routines/forms/day.dart @@ -309,8 +309,10 @@ class _DayFormWidgetState extends State { setState(() => isSaving = true); try { - await Provider.of(context, listen: false) - .editDay(widget.day); + await Provider.of( + context, + listen: false, + ).editDay(widget.day); if (context.mounted) { setState(() { errorMessage = const SizedBox.shrink(); @@ -330,8 +332,9 @@ class _DayFormWidgetState extends State { } } }, - child: - isSaving ? const FormProgressIndicator() : Text(AppLocalizations.of(context).save), + child: isSaving + ? const FormProgressIndicator() + : Text(AppLocalizations.of(context).save), ), const SizedBox(height: 5), ReorderableSlotList(widget.day.slots, widget.day), diff --git a/lib/widgets/routines/forms/reps_unit.dart b/lib/widgets/routines/forms/reps_unit.dart index cbe051c6..70e53c3b 100644 --- a/lib/widgets/routines/forms/reps_unit.dart +++ b/lib/widgets/routines/forms/reps_unit.dart @@ -59,15 +59,15 @@ class _RepetitionUnitInputWidgetState extends State { widget.onChanged(newValue.id); }); }, - items: Provider.of(context, listen: false) - .repetitionUnits + items: Provider.of(context, listen: false).repetitionUnits .map>((RepetitionUnit value) { - return DropdownMenuItem( - key: Key(value.id.toString()), - value: value, - child: Text(value.name), - ); - }).toList(), + return DropdownMenuItem( + key: Key(value.id.toString()), + value: value, + child: Text(value.name), + ); + }) + .toList(), ); } } diff --git a/lib/widgets/routines/forms/session.dart b/lib/widgets/routines/forms/session.dart index 443f0c6e..191f3615 100644 --- a/lib/widgets/routines/forms/session.dart +++ b/lib/widgets/routines/forms/session.dart @@ -37,16 +37,17 @@ class SessionForm extends StatefulWidget { static const SLIDER_START = -0.5; SessionForm(this._routineId, {Function()? onSaved, WorkoutSession? session, int? dayId}) - : _onSaved = onSaved, - _session = session ?? - WorkoutSession( - routineId: _routineId, - dayId: dayId, - impression: DEFAULT_IMPRESSION, - date: clock.now(), - timeEnd: TimeOfDay.fromDateTime(clock.now()), - timeStart: null, - ); + : _onSaved = onSaved, + _session = + session ?? + WorkoutSession( + routineId: _routineId, + dayId: dayId, + impression: DEFAULT_IMPRESSION, + date: clock.now(), + timeEnd: TimeOfDay.fromDateTime(clock.now()), + timeStart: null, + ); @override _SessionFormState createState() => _SessionFormState(); @@ -68,10 +69,12 @@ class _SessionFormState extends State { void initState() { super.initState(); - timeStartController.text = - widget._session.timeStart == null ? '' : timeToString(widget._session.timeStart)!; - timeEndController.text = - widget._session.timeEnd == null ? '' : timeToString(widget._session.timeEnd)!; + timeStartController.text = widget._session.timeStart == null + ? '' + : timeToString(widget._session.timeStart)!; + timeEndController.text = widget._session.timeEnd == null + ? '' + : timeToString(widget._session.timeEnd)!; notesController.text = widget._session.notes; selectedImpression[widget._session.impression - 1] = true; diff --git a/lib/widgets/routines/forms/slot.dart b/lib/widgets/routines/forms/slot.dart index 3c2b1ff2..59ab4aa9 100644 --- a/lib/widgets/routines/forms/slot.dart +++ b/lib/widgets/routines/forms/slot.dart @@ -53,9 +53,11 @@ class _SlotDetailWidgetState extends State { return Column( children: [ errorMessage, - ...widget.slot.entries.map((entry) => entry.hasProgressionRules - ? ProgressionRulesInfoBox(entry.exerciseObj) - : SlotEntryForm(entry, widget.routineId, simpleMode: widget.simpleMode)), + ...widget.slot.entries.map( + (entry) => entry.hasProgressionRules + ? ProgressionRulesInfoBox(entry.exerciseObj) + : SlotEntryForm(entry, widget.routineId, simpleMode: widget.simpleMode), + ), const SizedBox(height: 10), if (_showExerciseSearchBox || widget.slot.entries.isEmpty) ExerciseAutocompleter( diff --git a/lib/widgets/routines/forms/slot_entry.dart b/lib/widgets/routines/forms/slot_entry.dart index ec4d8aae..e5680800 100644 --- a/lib/widgets/routines/forms/slot_entry.dart +++ b/lib/widgets/routines/forms/slot_entry.dart @@ -85,8 +85,9 @@ class _SlotEntryFormState extends State { repetitionsController.text = widget.entry.repetitionsConfigs.first.value.round().toString(); } if (widget.entry.maxRepetitionsConfigs.isNotEmpty) { - maxRepetitionsController.text = - widget.entry.maxRepetitionsConfigs.first.value.round().toString(); + maxRepetitionsController.text = widget.entry.maxRepetitionsConfigs.first.value + .round() + .toString(); } if (widget.entry.restTimeConfigs.isNotEmpty) { @@ -384,8 +385,9 @@ class _SlotEntryFormState extends State { } } }, - child: - isSaving ? const FormProgressIndicator() : Text(AppLocalizations.of(context).save), + child: isSaving + ? const FormProgressIndicator() + : Text(AppLocalizations.of(context).save), ), const SizedBox(height: 10), ], @@ -417,9 +419,11 @@ class _SlotDetailWidgetState extends State { return Column( children: [ errorMessage, - ...widget.slot.entries.map((entry) => entry.hasProgressionRules - ? ProgressionRulesInfoBox(entry.exerciseObj) - : SlotEntryForm(entry, widget.routineId, simpleMode: widget.simpleMode)), + ...widget.slot.entries.map( + (entry) => entry.hasProgressionRules + ? ProgressionRulesInfoBox(entry.exerciseObj) + : SlotEntryForm(entry, widget.routineId, simpleMode: widget.simpleMode), + ), const SizedBox(height: 10), if (_showExerciseSearchBox || widget.slot.entries.isEmpty) ExerciseAutocompleter( diff --git a/lib/widgets/routines/forms/weight_unit.dart b/lib/widgets/routines/forms/weight_unit.dart index dee9a761..d47d7d0f 100644 --- a/lib/widgets/routines/forms/weight_unit.dart +++ b/lib/widgets/routines/forms/weight_unit.dart @@ -56,15 +56,15 @@ class _WeightUnitInputWidgetState extends State { widget.onChanged(newValue.id); }); }, - items: Provider.of(context, listen: false) - .weightUnits + items: Provider.of(context, listen: false).weightUnits .map>((WeightUnit value) { - return DropdownMenuItem( - key: Key(value.id.toString()), - value: value, - child: Text(value.name), - ); - }).toList(), + return DropdownMenuItem( + key: Key(value.id.toString()), + value: value, + child: Text(value.name), + ); + }) + .toList(), ); } } diff --git a/lib/widgets/routines/gym_mode/gym_mode.dart b/lib/widgets/routines/gym_mode/gym_mode.dart index ca53e163..60f11f40 100644 --- a/lib/widgets/routines/gym_mode/gym_mode.dart +++ b/lib/widgets/routines/gym_mode/gym_mode.dart @@ -75,9 +75,9 @@ class _GymModeState extends ConsumerState { // Re-fetch the current routine data to ensure we have the latest session // data since it is possible that the user created or deleted it from the // web interface. - await context - .read() - .fetchAndSetRoutineFull(widget._dayDataGym.day!.routineId); + await context.read().fetchAndSetRoutineFull( + widget._dayDataGym.day!.routineId, + ); widget._logger.fine('Refreshed routine data'); final validUntil = ref.read(gymStateProvider).validUntil; @@ -137,33 +137,39 @@ class _GymModeState extends ConsumerState { currentElement++; if (firstPage && state.showExercisePages) { - out.add(ExerciseOverview( - _controller, - exercise, - ratioCompleted, - state.exercisePages, - )); + out.add( + ExerciseOverview( + _controller, + exercise, + ratioCompleted, + state.exercisePages, + ), + ); } - out.add(LogPage( - _controller, - config, - slotData, - exercise, - routinesProvider.findById(widget._dayDataGym.day!.routineId), - ratioCompleted, - state.exercisePages, - widget._iteration, - )); + out.add( + LogPage( + _controller, + config, + slotData, + exercise, + routinesProvider.findById(widget._dayDataGym.day!.routineId), + ratioCompleted, + state.exercisePages, + widget._iteration, + ), + ); // If there is a rest time, add a countdown timer if (config.restTime != null) { - out.add(TimerCountdownWidget( - _controller, - config.restTime!.toInt(), - ratioCompleted, - state.exercisePages, - )); + out.add( + TimerCountdownWidget( + _controller, + config.restTime!.toInt(), + ratioCompleted, + state.exercisePages, + ), + ); } else { out.add(TimerWidget(_controller, ratioCompleted, state.exercisePages)); } diff --git a/lib/widgets/routines/gym_mode/log_page.dart b/lib/widgets/routines/gym_mode/log_page.dart index b2d322bf..55334cdc 100644 --- a/lib/widgets/routines/gym_mode/log_page.dart +++ b/lib/widgets/routines/gym_mode/log_page.dart @@ -59,8 +59,8 @@ class LogPage extends ConsumerStatefulWidget { this._exercisePages, int? iteration, ) : _log = Log.fromSetConfigData(_configData) - ..routineId = _workoutPlan.id! - ..iteration = iteration; + ..routineId = _workoutPlan.id! + ..iteration = iteration; @override _LogPageState createState() => _LogPageState(); @@ -250,8 +250,9 @@ class _LogPageState extends ConsumerState { rethrow; } }, - child: - _isSaving ? const FormProgressIndicator() : Text(AppLocalizations.of(context).save), + child: _isSaving + ? const FormProgressIndicator() + : Text(AppLocalizations.of(context).save), ), ], ), @@ -274,10 +275,9 @@ class _LogPageState extends ConsumerState { child: Center( child: Text( widget._configData.textRepr, - style: Theme.of(context) - .textTheme - .headlineMedium - ?.copyWith(color: Theme.of(context).colorScheme.primary), + style: Theme.of( + context, + ).textTheme.headlineMedium?.copyWith(color: Theme.of(context).colorScheme.primary), textAlign: TextAlign.center, ), ), @@ -499,7 +499,9 @@ class LogsWeightWidget extends ConsumerWidget { setStateCallback(() { log.weight = newValue; controller.text = numberFormat.format(newValue); - ref.read(plateCalculatorProvider.notifier).setWeight( + ref + .read(plateCalculatorProvider.notifier) + .setWeight( controller.text == '' ? 0 : newValue, ); }); @@ -519,7 +521,9 @@ class LogsWeightWidget extends ConsumerWidget { final newValue = numberFormat.parse(value); setStateCallback(() { log.weight = newValue; - ref.read(plateCalculatorProvider.notifier).setWeight( + ref + .read(plateCalculatorProvider.notifier) + .setWeight( controller.text == '' ? 0 : numberFormat.parse(controller.text), ); }); @@ -548,7 +552,9 @@ class LogsWeightWidget extends ConsumerWidget { setStateCallback(() { log.weight = newValue; controller.text = numberFormat.format(newValue); - ref.read(plateCalculatorProvider.notifier).setWeight( + ref + .read(plateCalculatorProvider.notifier) + .setWeight( controller.text == '' ? 0 : newValue, ); }); @@ -601,10 +607,12 @@ class LogsPastLogsWidget extends StatelessWidget { onTap: () { setStateCallback(() { // Text field - repetitionsController.text = - pastLog.repetitions != null ? numberFormat.format(pastLog.repetitions) : ''; - weightController.text = - pastLog.weight != null ? numberFormat.format(pastLog.weight) : ''; + repetitionsController.text = pastLog.repetitions != null + ? numberFormat.format(pastLog.repetitions) + : ''; + weightController.text = pastLog.weight != null + ? numberFormat.format(pastLog.weight) + : ''; // Drop downs log.rir = pastLog.rir; @@ -612,9 +620,11 @@ class LogsPastLogsWidget extends StatelessWidget { log.weightUnit = pastLog.weightUnitObj; ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(AppLocalizations.of(context).dataCopied), - )); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(AppLocalizations.of(context).dataCopied), + ), + ); }); }, contentPadding: const EdgeInsets.symmetric(horizontal: 40), diff --git a/lib/widgets/routines/gym_mode/session_page.dart b/lib/widgets/routines/gym_mode/session_page.dart index d54240e7..45509156 100644 --- a/lib/widgets/routines/gym_mode/session_page.dart +++ b/lib/widgets/routines/gym_mode/session_page.dart @@ -38,17 +38,19 @@ class SessionPage extends StatelessWidget { TimeOfDay start, this._exercisePages, { int? dayId, - }) : _session = _routine.sessions.map((sessionApi) => sessionApi.session).firstWhere( - (session) => session.date.isSameDayAs(clock.now()), - orElse: () => WorkoutSession( - dayId: dayId, - routineId: _routine.id!, - impression: DEFAULT_IMPRESSION, - date: clock.now(), - timeStart: start, - timeEnd: TimeOfDay.fromDateTime(clock.now()), - ), - ); + }) : _session = _routine.sessions + .map((sessionApi) => sessionApi.session) + .firstWhere( + (session) => session.date.isSameDayAs(clock.now()), + orElse: () => WorkoutSession( + dayId: dayId, + routineId: _routine.id!, + impression: DEFAULT_IMPRESSION, + date: clock.now(), + timeStart: start, + timeEnd: TimeOfDay.fromDateTime(clock.now()), + ), + ); @override Widget build(BuildContext context) { diff --git a/lib/widgets/routines/gym_mode/start_page.dart b/lib/widgets/routines/gym_mode/start_page.dart index 6afef502..1707ddf9 100644 --- a/lib/widgets/routines/gym_mode/start_page.dart +++ b/lib/widgets/routines/gym_mode/start_page.dart @@ -42,9 +42,11 @@ class StartPage extends StatelessWidget { width: 45, child: ExerciseImageWidget(image: exercise.getMainImage), ), - title: Text(exercise - .getTranslation(Localizations.localeOf(context).languageCode) - .name), + title: Text( + exercise + .getTranslation(Localizations.localeOf(context).languageCode) + .name, + ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: entry.value.map((text) => Text(text)).toList(), diff --git a/lib/widgets/routines/log.dart b/lib/widgets/routines/log.dart index 931c91db..9613ec1d 100644 --- a/lib/widgets/routines/log.dart +++ b/lib/widgets/routines/log.dart @@ -56,8 +56,9 @@ class _SessionInfoState extends State { style: Theme.of(context).textTheme.headlineSmall, ), subtitle: Text( - DateFormat.yMd(Localizations.localeOf(context).languageCode) - .format(widget._session.date), + DateFormat.yMd( + Localizations.localeOf(context).languageCode, + ).format(widget._session.date), ), onTap: () => setState(() => editMode = !editMode), trailing: Icon(editMode ? Icons.edit_off : Icons.edit), @@ -76,8 +77,9 @@ class _SessionInfoState extends State { context, i18n.timeStart, widget._session.timeStart != null - ? MaterialLocalizations.of(context) - .formatTimeOfDay(widget._session.timeStart!) + ? MaterialLocalizations.of( + context, + ).formatTimeOfDay(widget._session.timeStart!) : '-/-', ), _buildInfoRow( @@ -166,8 +168,9 @@ class DayLogWidget extends StatelessWidget { @override Widget build(BuildContext context) { - final sessionApi = - _routine.sessions.firstWhere((sessionApi) => sessionApi.session.date.isSameDayAs(_date)); + final sessionApi = _routine.sessions.firstWhere( + (sessionApi) => sessionApi.session.date.isSameDayAs(_date), + ); final exercises = sessionApi.exercises; return Card( @@ -175,15 +178,18 @@ class DayLogWidget extends StatelessWidget { children: [ SessionInfo(sessionApi.session), ...exercises.map((exercise) { - final translation = - exercise.getTranslation(Localizations.localeOf(context).languageCode); + final translation = exercise.getTranslation( + Localizations.localeOf(context).languageCode, + ); return Column( children: [ Text( translation.name, style: Theme.of(context).textTheme.titleMedium, ), - ...sessionApi.logs.where((l) => l.exerciseId == exercise.id).map( + ...sessionApi.logs + .where((l) => l.exerciseId == exercise.id) + .map( (log) => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/widgets/routines/routines_list.dart b/lib/widgets/routines/routines_list.dart index bede513d..151c6417 100644 --- a/lib/widgets/routines/routines_list.dart +++ b/lib/widgets/routines/routines_list.dart @@ -96,8 +96,9 @@ class _RoutinesListState extends State { builder: (BuildContext contextDialog) { return AlertDialog( content: Text( - AppLocalizations.of(context) - .confirmDelete(currentRoutine.name), + AppLocalizations.of( + context, + ).confirmDelete(currentRoutine.name), ), actions: [ TextButton( diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart index 755cc18d..c3e18255 100644 --- a/lib/widgets/weight/forms.dart +++ b/lib/widgets/weight/forms.dart @@ -34,7 +34,7 @@ class WeightForm extends StatelessWidget { final WeightEntry _weightEntry; WeightForm([WeightEntry? weightEntry]) - : _weightEntry = weightEntry ?? WeightEntry(date: DateTime.now()); + : _weightEntry = weightEntry ?? WeightEntry(date: DateTime.now()); @override Widget build(BuildContext context) { diff --git a/lib/widgets/weight/weight_overview.dart b/lib/widgets/weight/weight_overview.dart index 404ef853..f6f9050e 100644 --- a/lib/widgets/weight/weight_overview.dart +++ b/lib/widgets/weight/weight_overview.dart @@ -80,7 +80,8 @@ class WeightOverview extends StatelessWidget { return Card( child: ListTile( title: Text( - '${numberFormat.format(currentEntry.weight)} ${weightUnit(profile.isMetric, context)}'), + '${numberFormat.format(currentEntry.weight)} ${weightUnit(profile.isMetric, context)}', + ), subtitle: Text( DateFormat.yMd( Localizations.localeOf(context).languageCode, diff --git a/test/auth/auth_screen_test.dart b/test/auth/auth_screen_test.dart index e8e48696..2267b74a 100644 --- a/test/auth/auth_screen_test.dart +++ b/test/auth/auth_screen_test.dart @@ -94,21 +94,26 @@ void main() { buildSignature: 'buildSignature', ); - when(mockClient.post( - tLogin, - headers: anyNamed('headers'), - body: anyNamed('body'), - )).thenAnswer((_) => Future(() => Response(json.encode(responseLoginOk), 200))); + when( + mockClient.post( + tLogin, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ).thenAnswer((_) => Future(() => Response(json.encode(responseLoginOk), 200))); when(mockClient.get(any)).thenAnswer((_) => Future(() => Response('"1.2.3.4"', 200))); - when(mockClient.get(any, headers: anyNamed('headers'))) - .thenAnswer((_) => Future(() => Response('"1.2.3.4"', 200))); + when( + mockClient.get(any, headers: anyNamed('headers')), + ).thenAnswer((_) => Future(() => Response('"1.2.3.4"', 200))); - when(mockClient.post( - tRegistration, - headers: anyNamed('headers'), - body: anyNamed('body'), - )).thenAnswer((_) => Future(() => Response(json.encode(responseRegistrationOk), 201))); + when( + mockClient.post( + tRegistration, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ).thenAnswer((_) => Future(() => Response(json.encode(responseRegistrationOk), 201))); }); group('Login mode', () { @@ -147,11 +152,13 @@ void main() { expect(find.byKey(const ValueKey('inputApiToken')), findsNothing); expect(find.textContaining('An Error Occurred'), findsNothing); verify(mockClient.get(any)); - verify(mockClient.post( - tLogin, - headers: anyNamed('headers'), - body: json.encode({'username': 'testuser', 'password': '123456789'}), - )); + verify( + mockClient.post( + tLogin, + headers: anyNamed('headers'), + body: json.encode({'username': 'testuser', 'password': '123456789'}), + ), + ); }); testWidgets('Login - wrong username & password', (WidgetTester tester) async { @@ -161,11 +168,13 @@ void main() { final response = { 'non_field_errors': ['Username or password unknown'], }; - when(mockClient.post( - tLogin, - headers: anyNamed('headers'), - body: anyNamed('body'), - )).thenAnswer((_) => Future(() => Response(json.encode(response), 400))); + when( + mockClient.post( + tLogin, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ).thenAnswer((_) => Future(() => Response(json.encode(response), 400))); await tester.pumpWidget(getWidget()); @@ -178,11 +187,13 @@ void main() { // Assert expect(find.textContaining('Non field errors'), findsOne); expect(find.textContaining('Username or password unknown'), findsOne); - verify(mockClient.post( - tLogin, - headers: anyNamed('headers'), - body: json.encode({'username': 'testuser', 'password': '123456789'}), - )); + verify( + mockClient.post( + tLogin, + headers: anyNamed('headers'), + body: json.encode({'username': 'testuser', 'password': '123456789'}), + ), + ); }); testWidgets('Login - with API token - happy path', (WidgetTester tester) async { @@ -207,20 +218,26 @@ void main() { expect(find.byKey(const Key('inputPassword')), findsNothing); expect(find.textContaining('An Error Occurred'), findsNothing); - verify(mockClient.get( - tProfileCheck, - headers: argThat( - predicate((headers) => - headers is Map && - headers['authorization'] == 'Token 1234567890abcdef1234567890abcdef12345678'), - named: 'headers', + verify( + mockClient.get( + tProfileCheck, + headers: argThat( + predicate( + (headers) => + headers is Map && + headers['authorization'] == 'Token 1234567890abcdef1234567890abcdef12345678', + ), + named: 'headers', + ), ), - )); - verifyNever(mockClient.post( - any, - headers: anyNamed('headers'), - body: anyNamed('body'), - )); + ); + verifyNever( + mockClient.post( + any, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ); }); testWidgets('Login - with API token - wrong key', (WidgetTester tester) async { @@ -228,8 +245,9 @@ void main() { final response = { 'detail': ['Invalid token'], }; - when(mockClient.get(tProfileCheck, headers: anyNamed('headers'))) - .thenAnswer((_) => Future(() => Response(json.encode(response), 400))); + when( + mockClient.get(tProfileCheck, headers: anyNamed('headers')), + ).thenAnswer((_) => Future(() => Response(json.encode(response), 400))); await tester.pumpWidget(getWidget()); // Act @@ -247,20 +265,26 @@ void main() { // Assert expect(find.textContaining('Detail'), findsOne); expect(find.textContaining('Invalid token'), findsOne); - verify(mockClient.get( - tProfileCheck, - headers: argThat( - predicate((headers) => - headers is Map && - headers['authorization'] == 'Token 31e2ea0322c07b9df583a9b6d1e794f7139e78d4'), - named: 'headers', + verify( + mockClient.get( + tProfileCheck, + headers: argThat( + predicate( + (headers) => + headers is Map && + headers['authorization'] == 'Token 31e2ea0322c07b9df583a9b6d1e794f7139e78d4', + ), + named: 'headers', + ), ), - )); - verifyNever(mockClient.post( - any, - headers: anyNamed('headers'), - body: anyNamed('body'), - )); + ); + verifyNever( + mockClient.post( + any, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ); }); }); @@ -309,11 +333,13 @@ void main() { // Assert expect(find.textContaining('An Error Occurred'), findsNothing); - verify(mockClient.post( - tRegistration, - headers: anyNamed('headers'), - body: json.encode({'username': 'testuser', 'password': '123456789'}), - )); + verify( + mockClient.post( + tRegistration, + headers: anyNamed('headers'), + body: json.encode({'username': 'testuser', 'password': '123456789'}), + ), + ); }); testWidgets('Registration - password problems', (WidgetTester tester) async { @@ -328,11 +354,13 @@ void main() { ], }; - when(mockClient.post( - tRegistration, - headers: anyNamed('headers'), - body: anyNamed('body'), - )).thenAnswer((_) => Future(() => Response(json.encode(response), 400))); + when( + mockClient.post( + tRegistration, + headers: anyNamed('headers'), + body: anyNamed('body'), + ), + ).thenAnswer((_) => Future(() => Response(json.encode(response), 400))); await tester.pumpWidget(getWidget()); // Act @@ -348,11 +376,13 @@ void main() { expect(find.textContaining('This password is entirely numeric'), findsOne); expect(find.textContaining('This field must be unique'), findsOne); - verify(mockClient.post( - tRegistration, - headers: anyNamed('headers'), - body: json.encode({'username': 'testuser', 'password': '123456789'}), - )); + verify( + mockClient.post( + tRegistration, + headers: anyNamed('headers'), + body: json.encode({'username': 'testuser', 'password': '123456789'}), + ), + ); }); }); } diff --git a/test/auth/auth_screen_test.mocks.dart b/test/auth/auth_screen_test.mocks.dart index 3d3e2163..f0e0a5ab 100644 --- a/test/auth/auth_screen_test.mocks.dart +++ b/test/auth/auth_screen_test.mocks.dart @@ -31,9 +31,9 @@ class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeStreamedResponse_1 extends _i1.SmartFake implements _i2.StreamedResponse { @@ -41,9 +41,9 @@ class _FakeStreamedResponse_1 extends _i1.SmartFake implements _i2.StreamedRespo Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [Client]. @@ -60,20 +60,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> get( @@ -81,20 +84,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> post( @@ -104,28 +110,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> put( @@ -135,28 +144,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> patch( @@ -166,28 +178,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> delete( @@ -197,28 +212,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future read( @@ -226,20 +244,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future.value(_i5.dummyValue( - this, - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future); + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future.value( + _i5.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future); @override _i3.Future<_i6.Uint8List> readBytes( @@ -247,35 +268,40 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i3.Future<_i6.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), + ) + as _i3.Future<_i6.Uint8List>); @override - _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i3.Future<_i2.StreamedResponse>); + _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: _i3.Future<_i2.StreamedResponse>.value( + _FakeStreamedResponse_1( + this, + Invocation.method( + #send, + [request], + ), + ), + ), + ) + as _i3.Future<_i2.StreamedResponse>); @override void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/core/settings_test.mocks.dart b/test/core/settings_test.mocks.dart index 5f661123..529f3de0 100644 --- a/test/core/settings_test.mocks.dart +++ b/test/core/settings_test.mocks.dart @@ -48,9 +48,9 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeExerciseDatabase_1 extends _i1.SmartFake implements _i3.ExerciseDatabase { @@ -58,9 +58,9 @@ class _FakeExerciseDatabase_1 extends _i1.SmartFake implements _i3.ExerciseDatab Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeExercise_2 extends _i1.SmartFake implements _i4.Exercise { @@ -68,9 +68,9 @@ class _FakeExercise_2 extends _i1.SmartFake implements _i4.Exercise { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeExerciseCategory_3 extends _i1.SmartFake implements _i5.ExerciseCategory { @@ -78,9 +78,9 @@ class _FakeExerciseCategory_3 extends _i1.SmartFake implements _i5.ExerciseCateg Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeEquipment_4 extends _i1.SmartFake implements _i6.Equipment { @@ -88,9 +88,9 @@ class _FakeEquipment_4 extends _i1.SmartFake implements _i6.Equipment { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMuscle_5 extends _i1.SmartFake implements _i7.Muscle { @@ -98,9 +98,9 @@ class _FakeMuscle_5 extends _i1.SmartFake implements _i7.Muscle { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeLanguage_6 extends _i1.SmartFake implements _i8.Language { @@ -108,9 +108,9 @@ class _FakeLanguage_6 extends _i1.SmartFake implements _i8.Language { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredientDatabase_7 extends _i1.SmartFake implements _i9.IngredientDatabase { @@ -118,9 +118,9 @@ class _FakeIngredientDatabase_7 extends _i1.SmartFake implements _i9.IngredientD Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeNutritionalPlan_8 extends _i1.SmartFake implements _i10.NutritionalPlan { @@ -128,9 +128,9 @@ class _FakeNutritionalPlan_8 extends _i1.SmartFake implements _i10.NutritionalPl Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMeal_9 extends _i1.SmartFake implements _i11.Meal { @@ -138,9 +138,9 @@ class _FakeMeal_9 extends _i1.SmartFake implements _i11.Meal { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMealItem_10 extends _i1.SmartFake implements _i12.MealItem { @@ -148,9 +148,9 @@ class _FakeMealItem_10 extends _i1.SmartFake implements _i12.MealItem { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredient_11 extends _i1.SmartFake implements _i13.Ingredient { @@ -158,9 +158,9 @@ class _FakeIngredient_11 extends _i1.SmartFake implements _i13.Ingredient { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeSharedPreferencesAsync_12 extends _i1.SmartFake implements _i14.SharedPreferencesAsync { @@ -168,9 +168,9 @@ class _FakeSharedPreferencesAsync_12 extends _i1.SmartFake implements _i14.Share Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeAuthProvider_13 extends _i1.SmartFake implements _i15.AuthProvider { @@ -178,9 +178,9 @@ class _FakeAuthProvider_13 extends _i1.SmartFake implements _i15.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_14 extends _i1.SmartFake implements _i16.Client { @@ -188,9 +188,9 @@ class _FakeClient_14 extends _i1.SmartFake implements _i16.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_15 extends _i1.SmartFake implements Uri { @@ -198,9 +198,9 @@ class _FakeUri_15 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_16 extends _i1.SmartFake implements _i16.Response { @@ -208,9 +208,9 @@ class _FakeResponse_16 extends _i1.SmartFake implements _i16.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [ExercisesProvider]. @@ -222,159 +222,185 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider { } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i3.ExerciseDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeExerciseDatabase_1( - this, - Invocation.getter(#database), - ), - ) as _i3.ExerciseDatabase); + _i3.ExerciseDatabase get database => + (super.noSuchMethod( + Invocation.getter(#database), + returnValue: _FakeExerciseDatabase_1( + this, + Invocation.getter(#database), + ), + ) + as _i3.ExerciseDatabase); @override - List<_i4.Exercise> get exercises => (super.noSuchMethod( - Invocation.getter(#exercises), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); + List<_i4.Exercise> get exercises => + (super.noSuchMethod( + Invocation.getter(#exercises), + returnValue: <_i4.Exercise>[], + ) + as List<_i4.Exercise>); @override - List<_i4.Exercise> get filteredExercises => (super.noSuchMethod( - Invocation.getter(#filteredExercises), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); + List<_i4.Exercise> get filteredExercises => + (super.noSuchMethod( + Invocation.getter(#filteredExercises), + returnValue: <_i4.Exercise>[], + ) + as List<_i4.Exercise>); @override - Map> get exerciseByVariation => (super.noSuchMethod( - Invocation.getter(#exerciseByVariation), - returnValue: >{}, - ) as Map>); + Map> get exerciseByVariation => + (super.noSuchMethod( + Invocation.getter(#exerciseByVariation), + returnValue: >{}, + ) + as Map>); @override - List<_i5.ExerciseCategory> get categories => (super.noSuchMethod( - Invocation.getter(#categories), - returnValue: <_i5.ExerciseCategory>[], - ) as List<_i5.ExerciseCategory>); + List<_i5.ExerciseCategory> get categories => + (super.noSuchMethod( + Invocation.getter(#categories), + returnValue: <_i5.ExerciseCategory>[], + ) + as List<_i5.ExerciseCategory>); @override - List<_i7.Muscle> get muscles => (super.noSuchMethod( - Invocation.getter(#muscles), - returnValue: <_i7.Muscle>[], - ) as List<_i7.Muscle>); + List<_i7.Muscle> get muscles => + (super.noSuchMethod( + Invocation.getter(#muscles), + returnValue: <_i7.Muscle>[], + ) + as List<_i7.Muscle>); @override - List<_i6.Equipment> get equipment => (super.noSuchMethod( - Invocation.getter(#equipment), - returnValue: <_i6.Equipment>[], - ) as List<_i6.Equipment>); + List<_i6.Equipment> get equipment => + (super.noSuchMethod( + Invocation.getter(#equipment), + returnValue: <_i6.Equipment>[], + ) + as List<_i6.Equipment>); @override - List<_i8.Language> get languages => (super.noSuchMethod( - Invocation.getter(#languages), - returnValue: <_i8.Language>[], - ) as List<_i8.Language>); + List<_i8.Language> get languages => + (super.noSuchMethod( + Invocation.getter(#languages), + returnValue: <_i8.Language>[], + ) + as List<_i8.Language>); @override set database(_i3.ExerciseDatabase? value) => super.noSuchMethod( - Invocation.setter( - #database, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #database, + value, + ), + returnValueForMissingStub: null, + ); @override set exercises(List<_i4.Exercise>? value) => super.noSuchMethod( - Invocation.setter( - #exercises, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #exercises, + value, + ), + returnValueForMissingStub: null, + ); @override set filteredExercises(List<_i4.Exercise>? newFilteredExercises) => super.noSuchMethod( - Invocation.setter( - #filteredExercises, - newFilteredExercises, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #filteredExercises, + newFilteredExercises, + ), + returnValueForMissingStub: null, + ); @override set languages(List<_i8.Language>? languages) => super.noSuchMethod( - Invocation.setter( - #languages, - languages, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #languages, + languages, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override - _i18.Future setFilters(_i17.Filters? newFilters) => (super.noSuchMethod( - Invocation.method( - #setFilters, - [newFilters], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future setFilters(_i17.Filters? newFilters) => + (super.noSuchMethod( + Invocation.method( + #setFilters, + [newFilters], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override void initFilters() => super.noSuchMethod( - Invocation.method( - #initFilters, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #initFilters, + [], + ), + returnValueForMissingStub: null, + ); @override - _i18.Future findByFilters() => (super.noSuchMethod( - Invocation.method( - #findByFilters, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future findByFilters() => + (super.noSuchMethod( + Invocation.method( + #findByFilters, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i4.Exercise findExerciseById(int? id) => (super.noSuchMethod( - Invocation.method( - #findExerciseById, - [id], - ), - returnValue: _FakeExercise_2( - this, - Invocation.method( - #findExerciseById, - [id], - ), - ), - ) as _i4.Exercise); + _i4.Exercise findExerciseById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findExerciseById, + [id], + ), + returnValue: _FakeExercise_2( + this, + Invocation.method( + #findExerciseById, + [id], + ), + ), + ) + as _i4.Exercise); @override List<_i4.Exercise> findExercisesByVariationId( @@ -382,132 +408,153 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider { int? exerciseIdToExclude, }) => (super.noSuchMethod( - Invocation.method( - #findExercisesByVariationId, - [variationId], - {#exerciseIdToExclude: exerciseIdToExclude}, - ), - returnValue: <_i4.Exercise>[], - ) as List<_i4.Exercise>); + Invocation.method( + #findExercisesByVariationId, + [variationId], + {#exerciseIdToExclude: exerciseIdToExclude}, + ), + returnValue: <_i4.Exercise>[], + ) + as List<_i4.Exercise>); @override - _i5.ExerciseCategory findCategoryById(int? id) => (super.noSuchMethod( - Invocation.method( - #findCategoryById, - [id], - ), - returnValue: _FakeExerciseCategory_3( - this, - Invocation.method( - #findCategoryById, - [id], - ), - ), - ) as _i5.ExerciseCategory); + _i5.ExerciseCategory findCategoryById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findCategoryById, + [id], + ), + returnValue: _FakeExerciseCategory_3( + this, + Invocation.method( + #findCategoryById, + [id], + ), + ), + ) + as _i5.ExerciseCategory); @override - _i6.Equipment findEquipmentById(int? id) => (super.noSuchMethod( - Invocation.method( - #findEquipmentById, - [id], - ), - returnValue: _FakeEquipment_4( - this, - Invocation.method( - #findEquipmentById, - [id], - ), - ), - ) as _i6.Equipment); + _i6.Equipment findEquipmentById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findEquipmentById, + [id], + ), + returnValue: _FakeEquipment_4( + this, + Invocation.method( + #findEquipmentById, + [id], + ), + ), + ) + as _i6.Equipment); @override - _i7.Muscle findMuscleById(int? id) => (super.noSuchMethod( - Invocation.method( - #findMuscleById, - [id], - ), - returnValue: _FakeMuscle_5( - this, - Invocation.method( - #findMuscleById, - [id], - ), - ), - ) as _i7.Muscle); + _i7.Muscle findMuscleById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findMuscleById, + [id], + ), + returnValue: _FakeMuscle_5( + this, + Invocation.method( + #findMuscleById, + [id], + ), + ), + ) + as _i7.Muscle); @override - _i8.Language findLanguageById(int? id) => (super.noSuchMethod( - Invocation.method( - #findLanguageById, - [id], - ), - returnValue: _FakeLanguage_6( - this, - Invocation.method( - #findLanguageById, - [id], - ), - ), - ) as _i8.Language); + _i8.Language findLanguageById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findLanguageById, + [id], + ), + returnValue: _FakeLanguage_6( + this, + Invocation.method( + #findLanguageById, + [id], + ), + ), + ) + as _i8.Language); @override - _i18.Future fetchAndSetCategoriesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategoriesFromApi, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetCategoriesFromApi() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetCategoriesFromApi, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetMusclesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetMusclesFromApi, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetMusclesFromApi() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetMusclesFromApi, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetEquipmentsFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetEquipmentsFromApi, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetEquipmentsFromApi() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetEquipmentsFromApi, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetLanguagesFromApi() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLanguagesFromApi, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetLanguagesFromApi() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLanguagesFromApi, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetAllExercises() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllExercises, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetAllExercises() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllExercises, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future<_i4.Exercise?> fetchAndSetExercise(int? exerciseId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetExercise, - [exerciseId], - ), - returnValue: _i18.Future<_i4.Exercise?>.value(), - ) as _i18.Future<_i4.Exercise?>); + _i18.Future<_i4.Exercise?> fetchAndSetExercise(int? exerciseId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetExercise, + [exerciseId], + ), + returnValue: _i18.Future<_i4.Exercise?>.value(), + ) + as _i18.Future<_i4.Exercise?>); @override _i18.Future<_i4.Exercise> handleUpdateExerciseFromApi( @@ -515,55 +562,64 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider { int? exerciseId, ) => (super.noSuchMethod( - Invocation.method( - #handleUpdateExerciseFromApi, - [ - database, - exerciseId, - ], - ), - returnValue: _i18.Future<_i4.Exercise>.value(_FakeExercise_2( - this, - Invocation.method( - #handleUpdateExerciseFromApi, - [ - database, - exerciseId, - ], - ), - )), - ) as _i18.Future<_i4.Exercise>); + Invocation.method( + #handleUpdateExerciseFromApi, + [ + database, + exerciseId, + ], + ), + returnValue: _i18.Future<_i4.Exercise>.value( + _FakeExercise_2( + this, + Invocation.method( + #handleUpdateExerciseFromApi, + [ + database, + exerciseId, + ], + ), + ), + ), + ) + as _i18.Future<_i4.Exercise>); @override - _i18.Future initCacheTimesLocalPrefs({dynamic forceInit = false}) => (super.noSuchMethod( - Invocation.method( - #initCacheTimesLocalPrefs, - [], - {#forceInit: forceInit}, - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future initCacheTimesLocalPrefs({dynamic forceInit = false}) => + (super.noSuchMethod( + Invocation.method( + #initCacheTimesLocalPrefs, + [], + {#forceInit: forceInit}, + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future clearAllCachesAndPrefs() => (super.noSuchMethod( - Invocation.method( - #clearAllCachesAndPrefs, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future clearAllCachesAndPrefs() => + (super.noSuchMethod( + Invocation.method( + #clearAllCachesAndPrefs, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetInitialData() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetInitialData, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetInitialData() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetInitialData, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future setExercisesFromDatabase( @@ -571,64 +627,75 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider { bool? forceDeleteCache = false, }) => (super.noSuchMethod( - Invocation.method( - #setExercisesFromDatabase, - [database], - {#forceDeleteCache: forceDeleteCache}, - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setExercisesFromDatabase, + [database], + {#forceDeleteCache: forceDeleteCache}, + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future updateExerciseCache(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #updateExerciseCache, - [database], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future updateExerciseCache(_i3.ExerciseDatabase? database) => + (super.noSuchMethod( + Invocation.method( + #updateExerciseCache, + [database], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetMuscles(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetMuscles, - [database], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetMuscles(_i3.ExerciseDatabase? database) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetMuscles, + [database], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetCategories(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategories, - [database], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetCategories(_i3.ExerciseDatabase? database) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetCategories, + [database], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetLanguages(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLanguages, - [database], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetLanguages(_i3.ExerciseDatabase? database) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLanguages, + [database], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetEquipments(_i3.ExerciseDatabase? database) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetEquipments, - [database], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetEquipments(_i3.ExerciseDatabase? database) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetEquipments, + [database], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future> searchExercise( @@ -637,52 +704,53 @@ class MockExercisesProvider extends _i1.Mock implements _i17.ExercisesProvider { bool? searchEnglish = false, }) => (super.noSuchMethod( - Invocation.method( - #searchExercise, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i18.Future>.value(<_i4.Exercise>[]), - ) as _i18.Future>); + Invocation.method( + #searchExercise, + [name], + { + #languageCode: languageCode, + #searchEnglish: searchEnglish, + }, + ), + returnValue: _i18.Future>.value(<_i4.Exercise>[]), + ) + as _i18.Future>); @override void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [NutritionPlansProvider]. @@ -694,173 +762,209 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i9.IngredientDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_7( - this, - Invocation.getter(#database), - ), - ) as _i9.IngredientDatabase); + _i9.IngredientDatabase get database => + (super.noSuchMethod( + Invocation.getter(#database), + returnValue: _FakeIngredientDatabase_7( + this, + Invocation.getter(#database), + ), + ) + as _i9.IngredientDatabase); @override - List<_i13.Ingredient> get ingredients => (super.noSuchMethod( - Invocation.getter(#ingredients), - returnValue: <_i13.Ingredient>[], - ) as List<_i13.Ingredient>); + List<_i13.Ingredient> get ingredients => + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i13.Ingredient>[], + ) + as List<_i13.Ingredient>); @override - List<_i10.NutritionalPlan> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i10.NutritionalPlan>[], - ) as List<_i10.NutritionalPlan>); + List<_i10.NutritionalPlan> get items => + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i10.NutritionalPlan>[], + ) + as List<_i10.NutritionalPlan>); @override set database(_i9.IngredientDatabase? value) => super.noSuchMethod( - Invocation.setter( - #database, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #database, + value, + ), + returnValueForMissingStub: null, + ); @override set ingredients(List<_i13.Ingredient>? value) => super.noSuchMethod( - Invocation.setter( - #ingredients, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #ingredients, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i10.NutritionalPlan findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeNutritionalPlan_8( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i10.NutritionalPlan); + _i10.NutritionalPlan findById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findById, + [id], + ), + returnValue: _FakeNutritionalPlan_8( + this, + Invocation.method( + #findById, + [id], + ), + ), + ) + as _i10.NutritionalPlan); @override - _i11.Meal? findMealById(int? id) => (super.noSuchMethod(Invocation.method( - #findMealById, - [id], - )) as _i11.Meal?); + _i11.Meal? findMealById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findMealById, + [id], + ), + ) + as _i11.Meal?); @override - _i18.Future fetchAndSetAllPlansSparse() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansSparse, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetAllPlansSparse() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansSparse, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetAllPlansFull() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansFull, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetAllPlansFull() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansFull, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future<_i10.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - returnValue: _i18.Future<_i10.NutritionalPlan>.value(_FakeNutritionalPlan_8( - this, - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - )), - ) as _i18.Future<_i10.NutritionalPlan>); + _i18.Future<_i10.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + returnValue: _i18.Future<_i10.NutritionalPlan>.value( + _FakeNutritionalPlan_8( + this, + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + ), + ), + ) + as _i18.Future<_i10.NutritionalPlan>); @override - _i18.Future<_i10.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - returnValue: _i18.Future<_i10.NutritionalPlan>.value(_FakeNutritionalPlan_8( - this, - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - )), - ) as _i18.Future<_i10.NutritionalPlan>); + _i18.Future<_i10.NutritionalPlan> fetchAndSetPlanFull(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + returnValue: _i18.Future<_i10.NutritionalPlan>.value( + _FakeNutritionalPlan_8( + this, + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + ), + ), + ) + as _i18.Future<_i10.NutritionalPlan>); @override - _i18.Future<_i10.NutritionalPlan> addPlan(_i10.NutritionalPlan? planData) => (super.noSuchMethod( - Invocation.method( - #addPlan, - [planData], - ), - returnValue: _i18.Future<_i10.NutritionalPlan>.value(_FakeNutritionalPlan_8( - this, - Invocation.method( - #addPlan, - [planData], - ), - )), - ) as _i18.Future<_i10.NutritionalPlan>); + _i18.Future<_i10.NutritionalPlan> addPlan(_i10.NutritionalPlan? planData) => + (super.noSuchMethod( + Invocation.method( + #addPlan, + [planData], + ), + returnValue: _i18.Future<_i10.NutritionalPlan>.value( + _FakeNutritionalPlan_8( + this, + Invocation.method( + #addPlan, + [planData], + ), + ), + ), + ) + as _i18.Future<_i10.NutritionalPlan>); @override - _i18.Future editPlan(_i10.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #editPlan, - [plan], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future editPlan(_i10.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #editPlan, + [plan], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future deletePlan(int? id) => (super.noSuchMethod( - Invocation.method( - #deletePlan, - [id], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future deletePlan(int? id) => + (super.noSuchMethod( + Invocation.method( + #deletePlan, + [id], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future<_i11.Meal> addMeal( @@ -868,49 +972,58 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans int? planId, ) => (super.noSuchMethod( - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - returnValue: _i18.Future<_i11.Meal>.value(_FakeMeal_9( - this, - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - )), - ) as _i18.Future<_i11.Meal>); + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + returnValue: _i18.Future<_i11.Meal>.value( + _FakeMeal_9( + this, + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + ), + ), + ) + as _i18.Future<_i11.Meal>); @override - _i18.Future<_i11.Meal> editMeal(_i11.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #editMeal, - [meal], - ), - returnValue: _i18.Future<_i11.Meal>.value(_FakeMeal_9( - this, - Invocation.method( - #editMeal, - [meal], - ), - )), - ) as _i18.Future<_i11.Meal>); + _i18.Future<_i11.Meal> editMeal(_i11.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #editMeal, + [meal], + ), + returnValue: _i18.Future<_i11.Meal>.value( + _FakeMeal_9( + this, + Invocation.method( + #editMeal, + [meal], + ), + ), + ), + ) + as _i18.Future<_i11.Meal>); @override - _i18.Future deleteMeal(_i11.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #deleteMeal, - [meal], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future deleteMeal(_i11.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #deleteMeal, + [meal], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future<_i12.MealItem> addMealItem( @@ -918,44 +1031,51 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans _i11.Meal? meal, ) => (super.noSuchMethod( - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - returnValue: _i18.Future<_i12.MealItem>.value(_FakeMealItem_10( - this, - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - )), - ) as _i18.Future<_i12.MealItem>); + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + returnValue: _i18.Future<_i12.MealItem>.value( + _FakeMealItem_10( + this, + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + ), + ), + ) + as _i18.Future<_i12.MealItem>); @override - _i18.Future deleteMealItem(_i12.MealItem? mealItem) => (super.noSuchMethod( - Invocation.method( - #deleteMealItem, - [mealItem], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future deleteMealItem(_i12.MealItem? mealItem) => + (super.noSuchMethod( + Invocation.method( + #deleteMealItem, + [mealItem], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future clearIngredientCache() => (super.noSuchMethod( - Invocation.method( - #clearIngredientCache, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future clearIngredientCache() => + (super.noSuchMethod( + Invocation.method( + #clearIngredientCache, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future<_i13.Ingredient> fetchIngredient( @@ -963,30 +1083,35 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans _i9.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - returnValue: _i18.Future<_i13.Ingredient>.value(_FakeIngredient_11( - this, - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - )), - ) as _i18.Future<_i13.Ingredient>); + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + returnValue: _i18.Future<_i13.Ingredient>.value( + _FakeIngredient_11( + this, + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + ), + ), + ) + as _i18.Future<_i13.Ingredient>); @override - _i18.Future fetchIngredientsFromCache() => (super.noSuchMethod( - Invocation.method( - #fetchIngredientsFromCache, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchIngredientsFromCache() => + (super.noSuchMethod( + Invocation.method( + #fetchIngredientsFromCache, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future> searchIngredient( @@ -995,25 +1120,28 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans bool? searchEnglish = false, }) => (super.noSuchMethod( - Invocation.method( - #searchIngredient, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i18.Future>.value(<_i13.Ingredient>[]), - ) as _i18.Future>); + Invocation.method( + #searchIngredient, + [name], + { + #languageCode: languageCode, + #searchEnglish: searchEnglish, + }, + ), + returnValue: _i18.Future>.value(<_i13.Ingredient>[]), + ) + as _i18.Future>); @override - _i18.Future<_i13.Ingredient?> searchIngredientWithBarcode(String? barcode) => (super.noSuchMethod( - Invocation.method( - #searchIngredientWithBarcode, - [barcode], - ), - returnValue: _i18.Future<_i13.Ingredient?>.value(), - ) as _i18.Future<_i13.Ingredient?>); + _i18.Future<_i13.Ingredient?> searchIngredientWithBarcode(String? barcode) => + (super.noSuchMethod( + Invocation.method( + #searchIngredientWithBarcode, + [barcode], + ), + returnValue: _i18.Future<_i13.Ingredient?>.value(), + ) + as _i18.Future<_i13.Ingredient?>); @override _i18.Future logMealToDiary( @@ -1021,16 +1149,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans DateTime? mealDateTime, ) => (super.noSuchMethod( - Invocation.method( - #logMealToDiary, - [ - meal, - mealDateTime, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #logMealToDiary, + [ + meal, + mealDateTime, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future logIngredientToDiary( @@ -1039,17 +1168,18 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method( - #logIngredientToDiary, - [ - mealItem, - planId, - dateTime, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #logIngredientToDiary, + [ + mealItem, + planId, + dateTime, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future deleteLog( @@ -1057,62 +1187,65 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i20.NutritionPlans int? planId, ) => (super.noSuchMethod( - Invocation.method( - #deleteLog, - [ - logId, - planId, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #deleteLog, + [ + logId, + planId, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future fetchAndSetLogs(_i10.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLogs, - [plan], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetLogs(_i10.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLogs, + [plan], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [UserProvider]. @@ -1124,145 +1257,159 @@ class MockUserProvider extends _i1.Mock implements _i21.UserProvider { } @override - _i22.ThemeMode get themeMode => (super.noSuchMethod( - Invocation.getter(#themeMode), - returnValue: _i22.ThemeMode.system, - ) as _i22.ThemeMode); + _i22.ThemeMode get themeMode => + (super.noSuchMethod( + Invocation.getter(#themeMode), + returnValue: _i22.ThemeMode.system, + ) + as _i22.ThemeMode); @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i14.SharedPreferencesAsync get prefs => (super.noSuchMethod( - Invocation.getter(#prefs), - returnValue: _FakeSharedPreferencesAsync_12( - this, - Invocation.getter(#prefs), - ), - ) as _i14.SharedPreferencesAsync); + _i14.SharedPreferencesAsync get prefs => + (super.noSuchMethod( + Invocation.getter(#prefs), + returnValue: _FakeSharedPreferencesAsync_12( + this, + Invocation.getter(#prefs), + ), + ) + as _i14.SharedPreferencesAsync); @override set themeMode(_i22.ThemeMode? value) => super.noSuchMethod( - Invocation.setter( - #themeMode, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #themeMode, + value, + ), + returnValueForMissingStub: null, + ); @override set prefs(_i14.SharedPreferencesAsync? value) => super.noSuchMethod( - Invocation.setter( - #prefs, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #prefs, + value, + ), + returnValueForMissingStub: null, + ); @override set profile(_i23.Profile? value) => super.noSuchMethod( - Invocation.setter( - #profile, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #profile, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override void setThemeMode(_i22.ThemeMode? mode) => super.noSuchMethod( - Invocation.method( - #setThemeMode, - [mode], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #setThemeMode, + [mode], + ), + returnValueForMissingStub: null, + ); @override - _i18.Future fetchAndSetProfile() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetProfile, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetchAndSetProfile() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetProfile, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future saveProfile() => (super.noSuchMethod( - Invocation.method( - #saveProfile, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future saveProfile() => + (super.noSuchMethod( + Invocation.method( + #saveProfile, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future verifyEmail() => (super.noSuchMethod( - Invocation.method( - #verifyEmail, - [], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future verifyEmail() => + (super.noSuchMethod( + Invocation.method( + #verifyEmail, + [], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [WgerBaseProvider]. @@ -1274,50 +1421,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { } @override - _i15.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_13( - this, - Invocation.getter(#auth), - ), - ) as _i15.AuthProvider); + _i15.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_13( + this, + Invocation.getter(#auth), + ), + ) + as _i15.AuthProvider); @override - _i16.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_14( - this, - Invocation.getter(#client), - ), - ) as _i16.Client); + _i16.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_14( + this, + Invocation.getter(#client), + ), + ) + as _i16.Client); @override set auth(_i15.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i16.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -1327,46 +1480,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_15( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_15( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i18.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + _i18.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i18.Future>.value([]), - ) as _i18.Future>); + _i18.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i18.Future>.value([]), + ) + as _i18.Future>); @override _i18.Future> post( @@ -1374,15 +1532,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i18.Future>.value({}), + ) + as _i18.Future>); @override _i18.Future> patch( @@ -1390,15 +1549,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i18.Future>.value({}), + ) + as _i18.Future>); @override _i18.Future<_i16.Response> deleteRequest( @@ -1406,24 +1566,27 @@ class MockWgerBaseProvider extends _i1.Mock implements _i2.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i18.Future<_i16.Response>.value(_FakeResponse_16( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i18.Future<_i16.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i18.Future<_i16.Response>.value( + _FakeResponse_16( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i18.Future<_i16.Response>); } /// A class which mocks [SharedPreferencesAsync]. @@ -1436,78 +1599,94 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen } @override - _i18.Future> getKeys({Set? allowList}) => (super.noSuchMethod( - Invocation.method( - #getKeys, - [], - {#allowList: allowList}, - ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + _i18.Future> getKeys({Set? allowList}) => + (super.noSuchMethod( + Invocation.method( + #getKeys, + [], + {#allowList: allowList}, + ), + returnValue: _i18.Future>.value({}), + ) + as _i18.Future>); @override - _i18.Future> getAll({Set? allowList}) => (super.noSuchMethod( - Invocation.method( - #getAll, - [], - {#allowList: allowList}, - ), - returnValue: _i18.Future>.value({}), - ) as _i18.Future>); + _i18.Future> getAll({Set? allowList}) => + (super.noSuchMethod( + Invocation.method( + #getAll, + [], + {#allowList: allowList}, + ), + returnValue: _i18.Future>.value({}), + ) + as _i18.Future>); @override - _i18.Future getBool(String? key) => (super.noSuchMethod( - Invocation.method( - #getBool, - [key], - ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + _i18.Future getBool(String? key) => + (super.noSuchMethod( + Invocation.method( + #getBool, + [key], + ), + returnValue: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future getInt(String? key) => (super.noSuchMethod( - Invocation.method( - #getInt, - [key], - ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + _i18.Future getInt(String? key) => + (super.noSuchMethod( + Invocation.method( + #getInt, + [key], + ), + returnValue: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future getDouble(String? key) => (super.noSuchMethod( - Invocation.method( - #getDouble, - [key], - ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + _i18.Future getDouble(String? key) => + (super.noSuchMethod( + Invocation.method( + #getDouble, + [key], + ), + returnValue: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future getString(String? key) => (super.noSuchMethod( - Invocation.method( - #getString, - [key], - ), - returnValue: _i18.Future.value(), - ) as _i18.Future); + _i18.Future getString(String? key) => + (super.noSuchMethod( + Invocation.method( + #getString, + [key], + ), + returnValue: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future?> getStringList(String? key) => (super.noSuchMethod( - Invocation.method( - #getStringList, - [key], - ), - returnValue: _i18.Future?>.value(), - ) as _i18.Future?>); + _i18.Future?> getStringList(String? key) => + (super.noSuchMethod( + Invocation.method( + #getStringList, + [key], + ), + returnValue: _i18.Future?>.value(), + ) + as _i18.Future?>); @override - _i18.Future containsKey(String? key) => (super.noSuchMethod( - Invocation.method( - #containsKey, - [key], - ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + _i18.Future containsKey(String? key) => + (super.noSuchMethod( + Invocation.method( + #containsKey, + [key], + ), + returnValue: _i18.Future.value(false), + ) + as _i18.Future); @override _i18.Future setBool( @@ -1515,16 +1694,17 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen bool? value, ) => (super.noSuchMethod( - Invocation.method( - #setBool, - [ - key, - value, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setBool, + [ + key, + value, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future setInt( @@ -1532,16 +1712,17 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen int? value, ) => (super.noSuchMethod( - Invocation.method( - #setInt, - [ - key, - value, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setInt, + [ + key, + value, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future setDouble( @@ -1549,16 +1730,17 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen double? value, ) => (super.noSuchMethod( - Invocation.method( - #setDouble, - [ - key, - value, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setDouble, + [ + key, + value, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future setString( @@ -1566,16 +1748,17 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen String? value, ) => (super.noSuchMethod( - Invocation.method( - #setString, - [ - key, - value, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setString, + [ + key, + value, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override _i18.Future setStringList( @@ -1583,35 +1766,40 @@ class MockSharedPreferencesAsync extends _i1.Mock implements _i14.SharedPreferen List? value, ) => (super.noSuchMethod( - Invocation.method( - #setStringList, - [ - key, - value, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + Invocation.method( + #setStringList, + [ + key, + value, + ], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future remove(String? key) => (super.noSuchMethod( - Invocation.method( - #remove, - [key], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future remove(String? key) => + (super.noSuchMethod( + Invocation.method( + #remove, + [key], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); @override - _i18.Future clear({Set? allowList}) => (super.noSuchMethod( - Invocation.method( - #clear, - [], - {#allowList: allowList}, - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + _i18.Future clear({Set? allowList}) => + (super.noSuchMethod( + Invocation.method( + #clear, + [], + {#allowList: allowList}, + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) + as _i18.Future); } diff --git a/test/exercises/exercise_provider_db_test.dart b/test/exercises/exercise_provider_db_test.dart index 1b092bf8..3862baa6 100644 --- a/test/exercises/exercise_provider_db_test.dart +++ b/test/exercises/exercise_provider_db_test.dart @@ -101,22 +101,26 @@ void main() { // Mock categories when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri); - when(mockBaseProvider.fetchPaginated(tCategoryEntriesUri)) - .thenAnswer((_) => Future.value(tCategoryMap['results'])); + when( + mockBaseProvider.fetchPaginated(tCategoryEntriesUri), + ).thenAnswer((_) => Future.value(tCategoryMap['results'])); // Mock muscles when(mockBaseProvider.makeUrl(muscleUrl)).thenReturn(tMuscleEntriesUri); - when(mockBaseProvider.fetchPaginated(tMuscleEntriesUri)) - .thenAnswer((_) => Future.value(tMuscleMap['results'])); + when( + mockBaseProvider.fetchPaginated(tMuscleEntriesUri), + ).thenAnswer((_) => Future.value(tMuscleMap['results'])); // Mock equipment when(mockBaseProvider.makeUrl(equipmentUrl)).thenReturn(tEquipmentEntriesUri); - when(mockBaseProvider.fetchPaginated(tEquipmentEntriesUri)) - .thenAnswer((_) => Future.value(tEquipmentMap['results'])); + when( + mockBaseProvider.fetchPaginated(tEquipmentEntriesUri), + ).thenAnswer((_) => Future.value(tEquipmentMap['results'])); // Mock languages - when(mockBaseProvider.makeUrl(languageUrl, query: anyNamed('query'))) - .thenReturn(tLanguageEntriesUri); + when( + mockBaseProvider.makeUrl(languageUrl, query: anyNamed('query')), + ).thenReturn(tLanguageEntriesUri); when(mockBaseProvider.fetchPaginated(tLanguageEntriesUri)).thenAnswer( (_) => Future.value(tLanguageMap['results']), ); @@ -394,7 +398,9 @@ void main() { final valid = DateTime.now().add(const Duration(days: 1)); prefs.setString(PREFS_LAST_UPDATED_LANGUAGES, valid.toIso8601String()); - await database.into(database.exercises).insert( + await database + .into(database.exercises) + .insert( ExercisesCompanion.insert( id: tExerciseInfoMap['id'], data: json.encode(tExerciseInfoMap), @@ -426,7 +432,9 @@ void main() { test('fetching a known exercise - no API refresh', () async { // Arrange provider.languages = testLanguages; - await database.into(database.exercises).insert( + await database + .into(database.exercises) + .insert( ExercisesCompanion.insert( id: tExerciseInfoMap['id'], data: json.encode(tExerciseInfoMap), @@ -451,7 +459,9 @@ void main() { test('fetching a known exercise - needed API refresh - no new data', () async { // Arrange provider.languages = testLanguages; - await database.into(database.exercises).insert( + await database + .into(database.exercises) + .insert( ExercisesCompanion.insert( id: tExerciseInfoMap['id'], data: json.encode(tExerciseInfoMap), @@ -465,8 +475,9 @@ void main() { // Act await provider.handleUpdateExerciseFromApi(database, 9); - final exerciseDb = await (database.select(database.exercises)..where((e) => e.id.equals(9))) - .getSingleOrNull(); + final exerciseDb = await (database.select( + database.exercises, + )..where((e) => e.id.equals(9))).getSingleOrNull(); // Assert verify(mockBaseProvider.fetch(any)); @@ -482,7 +493,9 @@ void main() { final newData = Map.from(tExerciseInfoMap); newData['uuid'] = 'bf6d5557-1c49-48fd-922e-75d11f81d4eb'; - await database.into(database.exercises).insert( + await database + .into(database.exercises) + .insert( ExercisesCompanion.insert( id: newData['id'], data: json.encode(newData), @@ -496,8 +509,9 @@ void main() { // Act await provider.handleUpdateExerciseFromApi(database, 9); - final exerciseDb = await (database.select(database.exercises)..where((e) => e.id.equals(9))) - .getSingleOrNull(); + final exerciseDb = await (database.select( + database.exercises, + )..where((e) => e.id.equals(9))).getSingleOrNull(); final exerciseData = ExerciseApiData.fromString(exerciseDb!.data); // Assert diff --git a/test/exercises/exercise_provider_load_test.dart b/test/exercises/exercise_provider_load_test.dart index d72ceaf6..0e4152e6 100644 --- a/test/exercises/exercise_provider_load_test.dart +++ b/test/exercises/exercise_provider_load_test.dart @@ -57,10 +57,12 @@ void main() { when(mockBaseProvider.makeUrl(exerciseInfoUrl, id: 9)).thenReturn(tExerciseInfoUri); when(mockBaseProvider.makeUrl(exerciseInfoUrl, id: 1)).thenReturn(tExerciseInfoUri2); - when(mockBaseProvider.fetch(tExerciseInfoUri)) - .thenAnswer((_) => Future.value(tExerciseInfoMap)); - when(mockBaseProvider.fetch(tExerciseInfoUri2)) - .thenAnswer((_) => Future.value(tExerciseInfoMap)); + when( + mockBaseProvider.fetch(tExerciseInfoUri), + ).thenAnswer((_) => Future.value(tExerciseInfoMap)); + when( + mockBaseProvider.fetch(tExerciseInfoUri2), + ).thenAnswer((_) => Future.value(tExerciseInfoMap)); }); group('Correctly loads and parses data from the server', () { diff --git a/test/exercises/exercise_provider_test.dart b/test/exercises/exercise_provider_test.dart index f7534b4f..82a9d861 100644 --- a/test/exercises/exercise_provider_test.dart +++ b/test/exercises/exercise_provider_test.dart @@ -106,30 +106,36 @@ void main() { // Mock categories when(mockBaseProvider.makeUrl(categoryUrl)).thenReturn(tCategoryEntriesUri); - when(mockBaseProvider.fetchPaginated(tCategoryEntriesUri)) - .thenAnswer((_) => Future.value(tCategoryMap['results'])); + when( + mockBaseProvider.fetchPaginated(tCategoryEntriesUri), + ).thenAnswer((_) => Future.value(tCategoryMap['results'])); // Mock muscles when(mockBaseProvider.makeUrl(muscleUrl)).thenReturn(tMuscleEntriesUri); - when(mockBaseProvider.fetchPaginated(tMuscleEntriesUri)) - .thenAnswer((_) => Future.value(tMuscleMap['results'])); + when( + mockBaseProvider.fetchPaginated(tMuscleEntriesUri), + ).thenAnswer((_) => Future.value(tMuscleMap['results'])); // Mock equipment when(mockBaseProvider.makeUrl(equipmentUrl)).thenReturn(tEquipmentEntriesUri); - when(mockBaseProvider.fetchPaginated(tEquipmentEntriesUri)) - .thenAnswer((_) => Future.value(tEquipmentMap['results'])); + when( + mockBaseProvider.fetchPaginated(tEquipmentEntriesUri), + ).thenAnswer((_) => Future.value(tEquipmentMap['results'])); // Mock languages - when(mockBaseProvider.makeUrl(languageUrl, query: anyNamed('query'))) - .thenReturn(tLanguageEntriesUri); - when(mockBaseProvider.fetchPaginated(tLanguageEntriesUri)) - .thenAnswer((_) => Future.value(tLanguageMap['results'])); + when( + mockBaseProvider.makeUrl(languageUrl, query: anyNamed('query')), + ).thenReturn(tLanguageEntriesUri); + when( + mockBaseProvider.fetchPaginated(tLanguageEntriesUri), + ).thenAnswer((_) => Future.value(tLanguageMap['results'])); // Mock base info response when(mockBaseProvider.makeUrl(exerciseInfoUrl, id: 1)).thenReturn(tExerciseInfoUri); when(mockBaseProvider.makeUrl(exerciseInfoUrl, id: 2)).thenReturn(tExerciseInfoUri); - when(mockBaseProvider.fetch(tExerciseInfoUri)) - .thenAnswer((_) => Future.value(tExerciseInfoMap)); + when( + mockBaseProvider.fetch(tExerciseInfoUri), + ).thenAnswer((_) => Future.value(tExerciseInfoMap)); }); group('findCategoryById()', () { diff --git a/test/gallery/gallery_form_test.mocks.dart b/test/gallery/gallery_form_test.mocks.dart index 4d0a23b7..1d59d6be 100644 --- a/test/gallery/gallery_form_test.mocks.dart +++ b/test/gallery/gallery_form_test.mocks.dart @@ -33,9 +33,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -43,9 +43,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -53,9 +53,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -63,9 +63,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [GalleryProvider]. @@ -77,80 +77,90 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { } @override - List<_i5.Image> get images => (super.noSuchMethod( - Invocation.getter(#images), - returnValue: <_i5.Image>[], - ) as List<_i5.Image>); + List<_i5.Image> get images => + (super.noSuchMethod( + Invocation.getter(#images), + returnValue: <_i5.Image>[], + ) + as List<_i5.Image>); @override set images(List<_i5.Image>? value) => super.noSuchMethod( - Invocation.setter( - #images, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #images, + value, + ), + returnValueForMissingStub: null, + ); @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i6.Future fetchAndSetGallery() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetGallery, - [], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + _i6.Future fetchAndSetGallery() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetGallery, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override _i6.Future addImage( @@ -158,16 +168,17 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { _i7.XFile? imageFile, ) => (super.noSuchMethod( - Invocation.method( - #addImage, - [ - image, - imageFile, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method( + #addImage, + [ + image, + imageFile, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override _i6.Future editImage( @@ -175,36 +186,41 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { _i7.XFile? imageFile, ) => (super.noSuchMethod( - Invocation.method( - #editImage, - [ - image, - imageFile, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method( + #editImage, + [ + image, + imageFile, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override - _i6.Future deleteImage(_i5.Image? image) => (super.noSuchMethod( - Invocation.method( - #deleteImage, - [image], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + _i6.Future deleteImage(_i5.Image? image) => + (super.noSuchMethod( + Invocation.method( + #deleteImage, + [image], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -214,46 +230,51 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i6.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + _i6.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i6.Future.value(), + ) + as _i6.Future); @override - _i6.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + _i6.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i6.Future>.value([]), + ) + as _i6.Future>); @override _i6.Future> post( @@ -261,15 +282,16 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i6.Future>.value({}), + ) + as _i6.Future>); @override _i6.Future> patch( @@ -277,15 +299,16 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i6.Future>.value({}), + ) + as _i6.Future>); @override _i6.Future<_i3.Response> deleteRequest( @@ -293,58 +316,61 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i6.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i6.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i6.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i6.Future<_i3.Response>); @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/gallery/gallery_provider_test.dart b/test/gallery/gallery_provider_test.dart index b0e067b6..3fbb0f04 100644 --- a/test/gallery/gallery_provider_test.dart +++ b/test/gallery/gallery_provider_test.dart @@ -30,18 +30,22 @@ void main() { test('Test that fetch and set gallery', () async { final client = MockClient(); - when(client.get( - Uri.https('localhost', 'api/v2/gallery/'), - headers: anyNamed('headers'), - )).thenAnswer((_) async => http.Response( - '{"count":1,"next":null,"previous":null,"results":[' - '{"id":58,' - '"date":"2022-01-09",' - '"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",' - '"description":"eggsaddjujuit\'ddayhadIforcanview",' - '"height":1280,"width":960}]}', - 200, - )); + when( + client.get( + Uri.https('localhost', 'api/v2/gallery/'), + headers: anyNamed('headers'), + ), + ).thenAnswer( + (_) async => http.Response( + '{"count":1,"next":null,"previous":null,"results":[' + '{"id":58,' + '"date":"2022-01-09",' + '"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",' + '"description":"eggsaddjujuit\'ddayhadIforcanview",' + '"height":1280,"width":960}]}', + 200, + ), + ); final galleryProvider = GalleryProvider(testAuthProvider, [], client); @@ -54,17 +58,21 @@ void main() { test('Test that delete gallery photo', () async { final client = MockClient(); - when(client.delete( - Uri.https('localhost', 'api/v2/gallery/58/'), - headers: anyNamed('headers'), - )).thenAnswer((_) async => http.Response( - '{"id":58,' - '"date":"2022-01-09",' - '"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",' - '"description":"eggsaddjujuit\'ddayhadIforcanview",' - '"height":1280,"width":960}', - 200, - )); + when( + client.delete( + Uri.https('localhost', 'api/v2/gallery/58/'), + headers: anyNamed('headers'), + ), + ).thenAnswer( + (_) async => http.Response( + '{"id":58,' + '"date":"2022-01-09",' + '"image":"https://wger.de/media/gallery/170335/d2b9c9e0-d541-41ae-8786-a2ab459e3538.jpg",' + '"description":"eggsaddjujuit\'ddayhadIforcanview",' + '"height":1280,"width":960}', + 200, + ), + ); final galleryProvider = GalleryProvider(testAuthProvider, [], client); diff --git a/test/gallery/gallery_screen_test.mocks.dart b/test/gallery/gallery_screen_test.mocks.dart index fe133b28..8629cc7d 100644 --- a/test/gallery/gallery_screen_test.mocks.dart +++ b/test/gallery/gallery_screen_test.mocks.dart @@ -33,9 +33,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -43,9 +43,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -53,9 +53,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -63,9 +63,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [GalleryProvider]. @@ -77,80 +77,90 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { } @override - List<_i5.Image> get images => (super.noSuchMethod( - Invocation.getter(#images), - returnValue: <_i5.Image>[], - ) as List<_i5.Image>); + List<_i5.Image> get images => + (super.noSuchMethod( + Invocation.getter(#images), + returnValue: <_i5.Image>[], + ) + as List<_i5.Image>); @override set images(List<_i5.Image>? value) => super.noSuchMethod( - Invocation.setter( - #images, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #images, + value, + ), + returnValueForMissingStub: null, + ); @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i6.Future fetchAndSetGallery() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetGallery, - [], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + _i6.Future fetchAndSetGallery() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetGallery, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override _i6.Future addImage( @@ -158,16 +168,17 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { _i7.XFile? imageFile, ) => (super.noSuchMethod( - Invocation.method( - #addImage, - [ - image, - imageFile, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method( + #addImage, + [ + image, + imageFile, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override _i6.Future editImage( @@ -175,36 +186,41 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { _i7.XFile? imageFile, ) => (super.noSuchMethod( - Invocation.method( - #editImage, - [ - image, - imageFile, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method( + #editImage, + [ + image, + imageFile, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override - _i6.Future deleteImage(_i5.Image? image) => (super.noSuchMethod( - Invocation.method( - #deleteImage, - [image], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + _i6.Future deleteImage(_i5.Image? image) => + (super.noSuchMethod( + Invocation.method( + #deleteImage, + [image], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -214,46 +230,51 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i6.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + _i6.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i6.Future.value(), + ) + as _i6.Future); @override - _i6.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + _i6.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i6.Future>.value([]), + ) + as _i6.Future>); @override _i6.Future> post( @@ -261,15 +282,16 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i6.Future>.value({}), + ) + as _i6.Future>); @override _i6.Future> patch( @@ -277,15 +299,16 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i6.Future>.value({}), + ) + as _i6.Future>); @override _i6.Future<_i3.Response> deleteRequest( @@ -293,58 +316,61 @@ class MockGalleryProvider extends _i1.Mock implements _i4.GalleryProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i6.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i6.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i6.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i6.Future<_i3.Response>); @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/measurements/measurement_categories_screen_test.dart b/test/measurements/measurement_categories_screen_test.dart index ff4d94c3..a222f5df 100644 --- a/test/measurements/measurement_categories_screen_test.dart +++ b/test/measurements/measurement_categories_screen_test.dart @@ -37,14 +37,24 @@ void main() { setUp(() { mockMeasurementProvider = MockMeasurementProvider(); when(mockMeasurementProvider.categories).thenReturn([ - MeasurementCategory(id: 1, name: 'body fat', unit: '%', entries: [ - MeasurementEntry(id: 1, category: 1, date: DateTime(2021, 9, 1), value: 10, notes: ''), - MeasurementEntry(id: 2, category: 1, date: DateTime(2021, 9, 5), value: 11, notes: ''), - ]), - MeasurementCategory(id: 2, name: 'biceps', unit: 'cm', entries: [ - MeasurementEntry(id: 3, category: 2, date: DateTime(2021, 9, 1), value: 30, notes: ''), - MeasurementEntry(id: 4, category: 2, date: DateTime(2021, 9, 5), value: 40, notes: ''), - ]), + MeasurementCategory( + id: 1, + name: 'body fat', + unit: '%', + entries: [ + MeasurementEntry(id: 1, category: 1, date: DateTime(2021, 9, 1), value: 10, notes: ''), + MeasurementEntry(id: 2, category: 1, date: DateTime(2021, 9, 5), value: 11, notes: ''), + ], + ), + MeasurementCategory( + id: 2, + name: 'biceps', + unit: 'cm', + entries: [ + MeasurementEntry(id: 3, category: 2, date: DateTime(2021, 9, 1), value: 30, notes: ''), + MeasurementEntry(id: 4, category: 2, date: DateTime(2021, 9, 5), value: 40, notes: ''), + ], + ), ]); }); diff --git a/test/measurements/measurement_categories_screen_test.mocks.dart b/test/measurements/measurement_categories_screen_test.mocks.dart index 3f6d6cdf..33f55194 100644 --- a/test/measurements/measurement_categories_screen_test.mocks.dart +++ b/test/measurements/measurement_categories_screen_test.mocks.dart @@ -32,9 +32,9 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMeasurementCategory_1 extends _i1.SmartFake implements _i3.MeasurementCategory { @@ -42,9 +42,9 @@ class _FakeMeasurementCategory_1 extends _i1.SmartFake implements _i3.Measuremen Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [MeasurementProvider]. @@ -56,99 +56,117 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - List<_i3.MeasurementCategory> get categories => (super.noSuchMethod( - Invocation.getter(#categories), - returnValue: <_i3.MeasurementCategory>[], - ) as List<_i3.MeasurementCategory>); + List<_i3.MeasurementCategory> get categories => + (super.noSuchMethod( + Invocation.getter(#categories), + returnValue: <_i3.MeasurementCategory>[], + ) + as List<_i3.MeasurementCategory>); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i3.MeasurementCategory findCategoryById(int? id) => (super.noSuchMethod( - Invocation.method( - #findCategoryById, - [id], - ), - returnValue: _FakeMeasurementCategory_1( - this, - Invocation.method( - #findCategoryById, - [id], - ), - ), - ) as _i3.MeasurementCategory); + _i3.MeasurementCategory findCategoryById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findCategoryById, + [id], + ), + returnValue: _FakeMeasurementCategory_1( + this, + Invocation.method( + #findCategoryById, + [id], + ), + ), + ) + as _i3.MeasurementCategory); @override - _i5.Future fetchAndSetCategories() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategories, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetchAndSetCategories() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetCategories, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future fetchAndSetCategoryEntries(int? id) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetCategoryEntries, - [id], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetchAndSetCategoryEntries(int? id) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetCategoryEntries, + [id], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future fetchAndSetAllCategoriesAndEntries() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllCategoriesAndEntries, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetchAndSetAllCategoriesAndEntries() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllCategoriesAndEntries, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future addCategory(_i3.MeasurementCategory? category) => (super.noSuchMethod( - Invocation.method( - #addCategory, - [category], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future addCategory(_i3.MeasurementCategory? category) => + (super.noSuchMethod( + Invocation.method( + #addCategory, + [category], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future deleteCategory(int? id) => (super.noSuchMethod( - Invocation.method( - #deleteCategory, - [id], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future deleteCategory(int? id) => + (super.noSuchMethod( + Invocation.method( + #deleteCategory, + [id], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override _i5.Future editCategory( @@ -157,27 +175,30 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide String? newUnit, ) => (super.noSuchMethod( - Invocation.method( - #editCategory, - [ - id, - newName, - newUnit, - ], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + Invocation.method( + #editCategory, + [ + id, + newName, + newUnit, + ], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future addEntry(_i6.MeasurementEntry? entry) => (super.noSuchMethod( - Invocation.method( - #addEntry, - [entry], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future addEntry(_i6.MeasurementEntry? entry) => + (super.noSuchMethod( + Invocation.method( + #addEntry, + [entry], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override _i5.Future deleteEntry( @@ -185,16 +206,17 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide int? categoryId, ) => (super.noSuchMethod( - Invocation.method( - #deleteEntry, - [ - id, - categoryId, - ], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + Invocation.method( + #deleteEntry, + [ + id, + categoryId, + ], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override _i5.Future editEntry( @@ -205,53 +227,54 @@ class MockMeasurementProvider extends _i1.Mock implements _i4.MeasurementProvide DateTime? newDate, ) => (super.noSuchMethod( - Invocation.method( - #editEntry, - [ - id, - categoryId, - newValue, - newNotes, - newDate, - ], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + Invocation.method( + #editEntry, + [ + id, + categoryId, + newValue, + newNotes, + newDate, + ], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override void addListener(_i7.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i7.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/measurements/measurement_entries_screen_test.dart b/test/measurements/measurement_entries_screen_test.dart index c40785b7..4a721c51 100644 --- a/test/measurements/measurement_entries_screen_test.dart +++ b/test/measurements/measurement_entries_screen_test.dart @@ -37,10 +37,21 @@ void main() { setUp(() { mockMeasurementProvider = MockMeasurementProvider(); when(mockMeasurementProvider.findCategoryById(any)).thenReturn( - MeasurementCategory(id: 1, name: 'body fat', unit: '%', entries: [ - MeasurementEntry(id: 1, category: 1, date: DateTime(2021, 8, 1), value: 10.2, notes: ''), - MeasurementEntry(id: 1, category: 1, date: DateTime(2021, 8, 10), value: 18.1, notes: 'a'), - ]), + MeasurementCategory( + id: 1, + name: 'body fat', + unit: '%', + entries: [ + MeasurementEntry(id: 1, category: 1, date: DateTime(2021, 8, 1), value: 10.2, notes: ''), + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 8, 10), + value: 18.1, + notes: 'a', + ), + ], + ), ); mockNutritionPlansProvider = MockNutritionPlansProvider(); diff --git a/test/measurements/measurement_provider_test.dart b/test/measurements/measurement_provider_test.dart index 0b50dd1c..799ac261 100644 --- a/test/measurements/measurement_provider_test.dart +++ b/test/measurements/measurement_provider_test.dart @@ -23,8 +23,9 @@ void main() { const String categoryUrl = 'measurement-category'; const String entryUrl = 'measurement'; final Uri tCategoryUri = Uri(); - final Map tMeasurementCategoryMap = - jsonDecode(fixture('measurement/measurement_category_entries.json')); + final Map tMeasurementCategoryMap = jsonDecode( + fixture('measurement/measurement_category_entries.json'), + ); final Uri tCategoryEntriesUri = Uri( scheme: 'http', host: 'tedmosbyisajerk.com', @@ -33,31 +34,40 @@ void main() { ); const int tCategoryId = 1; - const MeasurementCategory tMeasurementCategory = - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'); + const MeasurementCategory tMeasurementCategory = MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + ); final List tMeasurementCategories = [ const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; - final Map tMeasurementCategoriesMap = - jsonDecode(fixture('measurement/measurement_categories.json')); + final Map tMeasurementCategoriesMap = jsonDecode( + fixture('measurement/measurement_categories.json'), + ); setUp(() { mockWgerBaseProvider = MockWgerBaseProvider(); measurementProvider = MeasurementProvider(mockWgerBaseProvider); when(mockWgerBaseProvider.makeUrl(any)).thenReturn(tCategoryUri); - when(mockWgerBaseProvider.makeUrl(any, id: anyNamed('id'), query: anyNamed('query'))) - .thenReturn(tCategoryUri); - when(mockWgerBaseProvider.fetchPaginated(any)) - .thenAnswer((realInvocation) => Future.value(tMeasurementCategoriesMap['results'])); + when( + mockWgerBaseProvider.makeUrl(any, id: anyNamed('id'), query: anyNamed('query')), + ).thenReturn(tCategoryUri); + when( + mockWgerBaseProvider.fetchPaginated(any), + ).thenAnswer((realInvocation) => Future.value(tMeasurementCategoriesMap['results'])); - when(mockWgerBaseProvider.makeUrl(entryUrl, query: anyNamed('query'))) - .thenReturn(tCategoryEntriesUri); - when(mockWgerBaseProvider.makeUrl(entryUrl, id: anyNamed('id'), query: anyNamed('query'))) - .thenReturn(tCategoryEntriesUri); - when(mockWgerBaseProvider.fetchPaginated(tCategoryEntriesUri)) - .thenAnswer((realInvocation) => Future.value(tMeasurementCategoryMap['results'])); + when( + mockWgerBaseProvider.makeUrl(entryUrl, query: anyNamed('query')), + ).thenReturn(tCategoryEntriesUri); + when( + mockWgerBaseProvider.makeUrl(entryUrl, id: anyNamed('id'), query: anyNamed('query')), + ).thenReturn(tCategoryEntriesUri); + when( + mockWgerBaseProvider.fetchPaginated(tCategoryEntriesUri), + ).thenAnswer((realInvocation) => Future.value(tMeasurementCategoryMap['results'])); }); group('clear()', () { @@ -130,10 +140,12 @@ void main() { await measurementProvider.fetchAndSetCategoryEntries(tCategoryId); // assert - verify(mockWgerBaseProvider.makeUrl( - entryUrl, - query: {'category': tCategoryId.toString(), 'limit': API_MAX_PAGE_SIZE}, - )); + verify( + mockWgerBaseProvider.makeUrl( + entryUrl, + query: {'category': tCategoryId.toString(), 'limit': API_MAX_PAGE_SIZE}, + ), + ); }); test('should fetch categories entries for id', () async { @@ -147,22 +159,27 @@ void main() { test('should add entries to category in list', () async { // arrange final List tMeasurementCategories = [ - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ - MeasurementEntry( - id: 1, - category: 1, - date: DateTime(2021, 7, 21), - value: 10, - notes: 'Some important notes', - ), - MeasurementEntry( - id: 2, - category: 1, - date: DateTime(2021, 7, 10), - value: 15.00, - notes: '', - ), - ]), + MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + entries: [ + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 7, 21), + value: 10, + notes: 'Some important notes', + ), + MeasurementEntry( + id: 2, + category: 1, + date: DateTime(2021, 7, 10), + value: 15.00, + notes: '', + ), + ], + ), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; @@ -175,20 +192,26 @@ void main() { }); group('addCategory()', () { - const MeasurementCategory tMeasurementCategoryWithoutId = - MeasurementCategory(id: null, name: 'Strength', unit: 'kN'); - final Map tMeasurementCategoryMap = - jsonDecode(fixture('measurement/measurement_category.json')); - final Map tMeasurementCategoryMapWithoutId = - jsonDecode(fixture('measurement/measurement_category_without_id_to_json.json')); + const MeasurementCategory tMeasurementCategoryWithoutId = MeasurementCategory( + id: null, + name: 'Strength', + unit: 'kN', + ); + final Map tMeasurementCategoryMap = jsonDecode( + fixture('measurement/measurement_category.json'), + ); + final Map tMeasurementCategoryMapWithoutId = jsonDecode( + fixture('measurement/measurement_category_without_id_to_json.json'), + ); final List tMeasurementCategoriesAdded = [ const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'), const MeasurementCategory(id: 1, name: 'Strength', unit: 'kN'), ]; setUp(() { - when(mockWgerBaseProvider.post(any, any)) - .thenAnswer((realInvocation) => Future.value(tMeasurementCategoryMap)); + when( + mockWgerBaseProvider.post(any, any), + ).thenAnswer((realInvocation) => Future.value(tMeasurementCategoryMap)); }); test("should post the MeasurementCategorie's Map", () async { @@ -222,8 +245,9 @@ void main() { 'should remove a MeasurementCategory from the categories list for an id and call the api to remove the MeasurementCategory', () async { // arrange - when(mockWgerBaseProvider.deleteRequest(any, any)) - .thenAnswer((realInvocation) => Future.value(Response('', 200))); + when( + mockWgerBaseProvider.deleteRequest(any, any), + ).thenAnswer((realInvocation) => Future.value(Response('', 200))); final List tMeasurementCategoriesOneDeleted = [ const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), @@ -262,13 +286,16 @@ void main() { group('editCategory()', () { const String tCategoryEditedName = 'Triceps'; const String tCategoryEditedUnit = 'm'; - final Map tCategoryMapEditedToJson = - jsonDecode(fixture('measurement/measurement_category_edited_to_json.json')); - final Map tCategoryMapEdited = - jsonDecode(fixture('measurement/measurement_category_edited.json')); + final Map tCategoryMapEditedToJson = jsonDecode( + fixture('measurement/measurement_category_edited_to_json.json'), + ); + final Map tCategoryMapEdited = jsonDecode( + fixture('measurement/measurement_category_edited.json'), + ); setUp(() async { - when(mockWgerBaseProvider.patch(any, any)) - .thenAnswer((realInvocation) => Future.value(tCategoryMapEdited)); + when( + mockWgerBaseProvider.patch(any, any), + ).thenAnswer((realInvocation) => Future.value(tCategoryMapEdited)); await measurementProvider.fetchAndSetCategories(); }); test('should add the new MeasurementCategory and remove the old one', () async { @@ -336,33 +363,40 @@ void main() { ); final List tMeasurementCategories = [ - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ - MeasurementEntry( - id: 1, - category: 1, - date: DateTime(2021, 7, 21), - value: 10, - notes: 'Some important notes', - ), - MeasurementEntry( - id: 2, - category: 1, - date: DateTime(2021, 7, 10), - value: 15.00, - notes: '', - ), - tMeasurementEntry, - ]), + MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + entries: [ + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 7, 21), + value: 10, + notes: 'Some important notes', + ), + MeasurementEntry( + id: 2, + category: 1, + date: DateTime(2021, 7, 10), + value: 15.00, + notes: '', + ), + tMeasurementEntry, + ], + ), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; setUp(() async { await measurementProvider.fetchAndSetCategories(); - final Map measurementEntryMap = - jsonDecode(fixture('measurement/measurement_entry.json')); - when(mockWgerBaseProvider.post(any, any)) - .thenAnswer((realInvocation) => Future.value(measurementEntryMap)); + final Map measurementEntryMap = jsonDecode( + fixture('measurement/measurement_entry.json'), + ); + when( + mockWgerBaseProvider.post(any, any), + ).thenAnswer((realInvocation) => Future.value(measurementEntryMap)); }); test('should make the post url', () async { @@ -375,8 +409,9 @@ void main() { test('should post the MeasurementEntryMap', () async { // arrange - final Map measurementEntryMapWithoutId = - jsonDecode(fixture('measurement/measurement_entry_without_id.json')); + final Map measurementEntryMapWithoutId = jsonDecode( + fixture('measurement/measurement_entry_without_id.json'), + ); // act await measurementProvider.addEntry(tMeasurementEntryWithoutId); @@ -408,10 +443,12 @@ void main() { value: 15.00, notes: '', ); - final Map measurementEntryMapWrongCategory = - jsonDecode(fixture('measurement/measurement_entry_wrong_category.json')); - when(mockWgerBaseProvider.post(any, any)) - .thenAnswer((realInvocation) => Future.value(measurementEntryMapWrongCategory)); + final Map measurementEntryMapWrongCategory = jsonDecode( + fixture('measurement/measurement_entry_wrong_category.json'), + ); + when( + mockWgerBaseProvider.post(any, any), + ).thenAnswer((realInvocation) => Future.value(measurementEntryMapWrongCategory)); // act & assert expect( @@ -424,15 +461,20 @@ void main() { group('deleteEntry()', () { const int tEntryId = 2; final List tMeasurementCategories = [ - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ - MeasurementEntry( - id: 1, - category: 1, - date: DateTime(2021, 7, 21), - value: 10, - notes: 'Some important notes', - ), - ]), + MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + entries: [ + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 7, 21), + value: 10, + notes: 'Some important notes', + ), + ], + ), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; @@ -440,8 +482,9 @@ void main() { await measurementProvider.fetchAndSetCategories(); await measurementProvider.fetchAndSetCategoryEntries(tCategoryId); - when(mockWgerBaseProvider.deleteRequest(any, any)) - .thenAnswer((realInvocation) => Future.value(Response('', 200))); + when( + mockWgerBaseProvider.deleteRequest(any, any), + ).thenAnswer((realInvocation) => Future.value(Response('', 200))); }); test("should remove a MeasurementEntry from the category's entries List for an id", () async { @@ -484,22 +527,27 @@ void main() { () { // arrange final List tMeasurementCategories = [ - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ - MeasurementEntry( - id: 1, - category: 1, - date: DateTime(2021, 7, 21), - value: 10, - notes: 'Some important notes', - ), - MeasurementEntry( - id: 2, - category: 1, - date: DateTime(2021, 7, 10), - value: 15.00, - notes: '', - ), - ]), + MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + entries: [ + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 7, 21), + value: 10, + notes: 'Some important notes', + ), + MeasurementEntry( + id: 2, + category: 1, + date: DateTime(2021, 7, 10), + value: 15.00, + notes: '', + ), + ], + ), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}')); @@ -525,33 +573,40 @@ void main() { const num tEntryEditedValue = 23; final DateTime tEntryEditedDate = DateTime(2021, 07, 21); const String tEntryEditedNote = 'I just wanted to edit this to see what happens'; - final Map tEntryMapEdited = - jsonDecode(fixture('measurement/measurement_entry_edited.json')); + final Map tEntryMapEdited = jsonDecode( + fixture('measurement/measurement_entry_edited.json'), + ); setUp(() async { - when(mockWgerBaseProvider.patch(any, any)) - .thenAnswer((realInvocation) => Future.value(tEntryMapEdited)); + when( + mockWgerBaseProvider.patch(any, any), + ).thenAnswer((realInvocation) => Future.value(tEntryMapEdited)); await measurementProvider.fetchAndSetCategories(); await measurementProvider.fetchAndSetCategoryEntries(1); }); test('should add the new MeasurementEntry and remove the old one', () async { // arrange final List tMeasurementCategoriesEdited = [ - MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ - MeasurementEntry( - id: 1, - category: 1, - date: DateTime(2021, 7, 21), - value: 23, - notes: 'I just wanted to edit this to see what happens', - ), - MeasurementEntry( - id: 2, - category: 1, - date: DateTime(2021, 7, 10), - value: 15.00, - notes: '', - ), - ]), + MeasurementCategory( + id: 1, + name: 'Strength', + unit: 'kN', + entries: [ + MeasurementEntry( + id: 1, + category: 1, + date: DateTime(2021, 7, 21), + value: 23, + notes: 'I just wanted to edit this to see what happens', + ), + MeasurementEntry( + id: 2, + category: 1, + date: DateTime(2021, 7, 10), + value: 15.00, + notes: '', + ), + ], + ), const MeasurementCategory(id: 2, name: 'Biceps', unit: 'cm'), ]; diff --git a/test/measurements/measurement_provider_test.mocks.dart b/test/measurements/measurement_provider_test.mocks.dart index 99933704..f806a71b 100644 --- a/test/measurements/measurement_provider_test.mocks.dart +++ b/test/measurements/measurement_provider_test.mocks.dart @@ -30,9 +30,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -40,9 +40,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -50,9 +50,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -60,9 +60,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [WgerBaseProvider]. @@ -74,50 +74,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { } @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -127,46 +133,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i5.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + _i5.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i5.Future>.value([]), + ) + as _i5.Future>); @override _i5.Future> post( @@ -174,15 +185,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future> patch( @@ -190,15 +202,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future<_i3.Response> deleteRequest( @@ -206,22 +219,25 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i5.Future<_i3.Response>); } diff --git a/test/nutrition/nutrition_provider_test.dart b/test/nutrition/nutrition_provider_test.dart index 40cae73d..81a03bec 100644 --- a/test/nutrition/nutrition_provider_test.dart +++ b/test/nutrition/nutrition_provider_test.dart @@ -82,8 +82,9 @@ void main() { when(mockWgerBaseProvider.makeUrl(planInfoUrl, id: anyNamed('id'))).thenReturn(planInfoUri); when(mockWgerBaseProvider.makeUrl(planUrl, id: anyNamed('id'))).thenReturn(planUri); when(mockWgerBaseProvider.makeUrl(diaryUrl, query: anyNamed('query'))).thenReturn(diaryUri); - when(mockWgerBaseProvider.makeUrl(ingredientInfoUrl, id: anyNamed('id'))) - .thenReturn(ingredientUri); + when( + mockWgerBaseProvider.makeUrl(ingredientInfoUrl, id: anyNamed('id')), + ).thenReturn(ingredientUri); when(mockWgerBaseProvider.fetch(planInfoUri)).thenAnswer( (realInvocation) => Future.value(nutritionalPlanInfoResponse), ); @@ -140,8 +141,10 @@ void main() { endDate: now.add(const Duration(days: 5)), creationDate: now.subtract(const Duration(days: 2)), ); - nutritionProvider = - NutritionPlansProvider(mockWgerBaseProvider, [olderPlan, newerPlan], database: database); + nutritionProvider = NutritionPlansProvider(mockWgerBaseProvider, [ + olderPlan, + newerPlan, + ], database: database); expect(nutritionProvider.currentPlan, equals(newerPlan)); }); }); @@ -192,8 +195,10 @@ void main() { startDate: now.subtract(const Duration(days: 10)), endDate: now.add(const Duration(days: 10)), ); - nutritionProvider = - NutritionPlansProvider(mockWgerBaseProvider, [plan, inactivePlan], database: database); + nutritionProvider = NutritionPlansProvider(mockWgerBaseProvider, [ + plan, + inactivePlan, + ], database: database); expect(nutritionProvider.currentPlan, equals(plan)); }); @@ -208,8 +213,10 @@ void main() { startDate: now.subtract(const Duration(days: 5)), endDate: now.add(const Duration(days: 5)), ); - nutritionProvider = - NutritionPlansProvider(mockWgerBaseProvider, [olderPlan, newerPlan], database: database); + nutritionProvider = NutritionPlansProvider(mockWgerBaseProvider, [ + olderPlan, + newerPlan, + ], database: database); expect(nutritionProvider.currentPlan, equals(newerPlan)); }); }); @@ -218,7 +225,9 @@ void main() { test('that if there is already valid data in the DB, the API is not hit', () async { // Arrange nutritionProvider.ingredients = []; - await database.into(database.ingredients).insert( + await database + .into(database.ingredients) + .insert( IngredientsCompanion.insert( id: ingredient59887Response['id'], data: json.encode(ingredient59887Response), @@ -239,7 +248,9 @@ void main() { test('fetching an ingredient not present in the DB, the API is hit', () async { // Arrange nutritionProvider.ingredients = []; - await database.into(database.ingredients).insert( + await database + .into(database.ingredients) + .insert( IngredientsCompanion.insert( id: ingredient59887Response['id'], data: json.encode(ingredient59887Response), diff --git a/test/nutrition/nutritional_meal_form_test.mocks.dart b/test/nutrition/nutritional_meal_form_test.mocks.dart index ef8ea874..36e897d8 100644 --- a/test/nutrition/nutritional_meal_form_test.mocks.dart +++ b/test/nutrition/nutritional_meal_form_test.mocks.dart @@ -35,9 +35,9 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase { @@ -45,9 +45,9 @@ class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientD Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan { @@ -55,9 +55,9 @@ class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPla Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { @@ -65,9 +65,9 @@ class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { @@ -75,9 +75,9 @@ class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { @@ -85,9 +85,9 @@ class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [NutritionPlansProvider]. @@ -99,173 +99,209 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i3.IngredientDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_1( - this, - Invocation.getter(#database), - ), - ) as _i3.IngredientDatabase); + _i3.IngredientDatabase get database => + (super.noSuchMethod( + Invocation.getter(#database), + returnValue: _FakeIngredientDatabase_1( + this, + Invocation.getter(#database), + ), + ) + as _i3.IngredientDatabase); @override - List<_i7.Ingredient> get ingredients => (super.noSuchMethod( - Invocation.getter(#ingredients), - returnValue: <_i7.Ingredient>[], - ) as List<_i7.Ingredient>); + List<_i7.Ingredient> get ingredients => + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i7.Ingredient>[], + ) + as List<_i7.Ingredient>); @override - List<_i4.NutritionalPlan> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i4.NutritionalPlan>[], - ) as List<_i4.NutritionalPlan>); + List<_i4.NutritionalPlan> get items => + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i4.NutritionalPlan>[], + ) + as List<_i4.NutritionalPlan>); @override set database(_i3.IngredientDatabase? value) => super.noSuchMethod( - Invocation.setter( - #database, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #database, + value, + ), + returnValueForMissingStub: null, + ); @override set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod( - Invocation.setter( - #ingredients, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #ingredients, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i4.NutritionalPlan findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeNutritionalPlan_2( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i4.NutritionalPlan); + _i4.NutritionalPlan findById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findById, + [id], + ), + returnValue: _FakeNutritionalPlan_2( + this, + Invocation.method( + #findById, + [id], + ), + ), + ) + as _i4.NutritionalPlan); @override - _i5.Meal? findMealById(int? id) => (super.noSuchMethod(Invocation.method( - #findMealById, - [id], - )) as _i5.Meal?); + _i5.Meal? findMealById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findMealById, + [id], + ), + ) + as _i5.Meal?); @override - _i9.Future fetchAndSetAllPlansSparse() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansSparse, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetAllPlansSparse() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansSparse, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future fetchAndSetAllPlansFull() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansFull, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetAllPlansFull() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansFull, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanFull(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future<_i4.NutritionalPlan> addPlan(_i4.NutritionalPlan? planData) => (super.noSuchMethod( - Invocation.method( - #addPlan, - [planData], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #addPlan, - [planData], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> addPlan(_i4.NutritionalPlan? planData) => + (super.noSuchMethod( + Invocation.method( + #addPlan, + [planData], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #addPlan, + [planData], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future editPlan(_i4.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #editPlan, - [plan], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future editPlan(_i4.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #editPlan, + [plan], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future deletePlan(int? id) => (super.noSuchMethod( - Invocation.method( - #deletePlan, - [id], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deletePlan(int? id) => + (super.noSuchMethod( + Invocation.method( + #deletePlan, + [id], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i5.Meal> addMeal( @@ -273,49 +309,58 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP int? planId, ) => (super.noSuchMethod( - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - returnValue: _i9.Future<_i5.Meal>.value(_FakeMeal_3( - this, - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - )), - ) as _i9.Future<_i5.Meal>); + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + returnValue: _i9.Future<_i5.Meal>.value( + _FakeMeal_3( + this, + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + ), + ), + ) + as _i9.Future<_i5.Meal>); @override - _i9.Future<_i5.Meal> editMeal(_i5.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #editMeal, - [meal], - ), - returnValue: _i9.Future<_i5.Meal>.value(_FakeMeal_3( - this, - Invocation.method( - #editMeal, - [meal], - ), - )), - ) as _i9.Future<_i5.Meal>); + _i9.Future<_i5.Meal> editMeal(_i5.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #editMeal, + [meal], + ), + returnValue: _i9.Future<_i5.Meal>.value( + _FakeMeal_3( + this, + Invocation.method( + #editMeal, + [meal], + ), + ), + ), + ) + as _i9.Future<_i5.Meal>); @override - _i9.Future deleteMeal(_i5.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #deleteMeal, - [meal], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deleteMeal(_i5.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #deleteMeal, + [meal], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i6.MealItem> addMealItem( @@ -323,44 +368,51 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i5.Meal? meal, ) => (super.noSuchMethod( - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - returnValue: _i9.Future<_i6.MealItem>.value(_FakeMealItem_4( - this, - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - )), - ) as _i9.Future<_i6.MealItem>); + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + returnValue: _i9.Future<_i6.MealItem>.value( + _FakeMealItem_4( + this, + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + ), + ), + ) + as _i9.Future<_i6.MealItem>); @override - _i9.Future deleteMealItem(_i6.MealItem? mealItem) => (super.noSuchMethod( - Invocation.method( - #deleteMealItem, - [mealItem], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deleteMealItem(_i6.MealItem? mealItem) => + (super.noSuchMethod( + Invocation.method( + #deleteMealItem, + [mealItem], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future clearIngredientCache() => (super.noSuchMethod( - Invocation.method( - #clearIngredientCache, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future clearIngredientCache() => + (super.noSuchMethod( + Invocation.method( + #clearIngredientCache, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i7.Ingredient> fetchIngredient( @@ -368,30 +420,35 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i3.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - returnValue: _i9.Future<_i7.Ingredient>.value(_FakeIngredient_5( - this, - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - )), - ) as _i9.Future<_i7.Ingredient>); + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + returnValue: _i9.Future<_i7.Ingredient>.value( + _FakeIngredient_5( + this, + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + ), + ), + ) + as _i9.Future<_i7.Ingredient>); @override - _i9.Future fetchIngredientsFromCache() => (super.noSuchMethod( - Invocation.method( - #fetchIngredientsFromCache, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchIngredientsFromCache() => + (super.noSuchMethod( + Invocation.method( + #fetchIngredientsFromCache, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future> searchIngredient( @@ -400,25 +457,28 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP bool? searchEnglish = false, }) => (super.noSuchMethod( - Invocation.method( - #searchIngredient, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i9.Future>.value(<_i7.Ingredient>[]), - ) as _i9.Future>); + Invocation.method( + #searchIngredient, + [name], + { + #languageCode: languageCode, + #searchEnglish: searchEnglish, + }, + ), + returnValue: _i9.Future>.value(<_i7.Ingredient>[]), + ) + as _i9.Future>); @override - _i9.Future<_i7.Ingredient?> searchIngredientWithBarcode(String? barcode) => (super.noSuchMethod( - Invocation.method( - #searchIngredientWithBarcode, - [barcode], - ), - returnValue: _i9.Future<_i7.Ingredient?>.value(), - ) as _i9.Future<_i7.Ingredient?>); + _i9.Future<_i7.Ingredient?> searchIngredientWithBarcode(String? barcode) => + (super.noSuchMethod( + Invocation.method( + #searchIngredientWithBarcode, + [barcode], + ), + returnValue: _i9.Future<_i7.Ingredient?>.value(), + ) + as _i9.Future<_i7.Ingredient?>); @override _i9.Future logMealToDiary( @@ -426,16 +486,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? mealDateTime, ) => (super.noSuchMethod( - Invocation.method( - #logMealToDiary, - [ - meal, - mealDateTime, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #logMealToDiary, + [ + meal, + mealDateTime, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future logIngredientToDiary( @@ -444,17 +505,18 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method( - #logIngredientToDiary, - [ - mealItem, - planId, - dateTime, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #logIngredientToDiary, + [ + mealItem, + planId, + dateTime, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future deleteLog( @@ -462,60 +524,63 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP int? planId, ) => (super.noSuchMethod( - Invocation.method( - #deleteLog, - [ - logId, - planId, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #deleteLog, + [ + logId, + planId, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future fetchAndSetLogs(_i4.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLogs, - [plan], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetLogs(_i4.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLogs, + [plan], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/nutrition/nutritional_meal_item_form_test.dart b/test/nutrition/nutritional_meal_item_form_test.dart index 224dc53e..9b4a0100 100644 --- a/test/nutrition/nutritional_meal_item_form_test.dart +++ b/test/nutrition/nutritional_meal_item_form_test.dart @@ -70,15 +70,18 @@ void main() { final MealItem mealItem = MealItem(ingredientId: ingredient.id, amount: 2); mockNutrition = MockNutritionPlansProvider(); - when(mockNutrition.searchIngredientWithBarcode('123')) - .thenAnswer((_) => Future.value(ingredient)); + when( + mockNutrition.searchIngredientWithBarcode('123'), + ).thenAnswer((_) => Future.value(ingredient)); when(mockNutrition.searchIngredientWithBarcode('')).thenAnswer((_) => Future.value(null)); when(mockNutrition.searchIngredientWithBarcode('222')).thenAnswer((_) => Future.value(null)); - when(mockNutrition.searchIngredient( - any, - languageCode: anyNamed('languageCode'), - searchEnglish: anyNamed('searchEnglish'), - )).thenAnswer( + when( + mockNutrition.searchIngredient( + any, + languageCode: anyNamed('languageCode'), + searchEnglish: anyNamed('searchEnglish'), + ), + ).thenAnswer( (_) => Future.value([ingredient1, ingredient2]), ); @@ -311,9 +314,11 @@ void main() { await tester.enterText(find.byKey(const Key('field-weight')), '2'); // once ID and weight are set, it'll fetchIngredient and show macros preview and ingredient image - when(mockNutrition.fetchIngredient(1)).thenAnswer((_) => Future.value( - Ingredient.fromJson(jsonDecode(fixture('nutrition/ingredientinfo_59887.json'))), - )); + when(mockNutrition.fetchIngredient(1)).thenAnswer( + (_) => Future.value( + Ingredient.fromJson(jsonDecode(fixture('nutrition/ingredientinfo_59887.json'))), + ), + ); await mockNetworkImagesFor(() => tester.pumpAndSettle()); expect(find.byKey(const Key('ingredient-scan-result-dialog')), findsNothing); diff --git a/test/nutrition/nutritional_plan_form_test.dart b/test/nutrition/nutritional_plan_form_test.dart index 5b67fdf6..73f26084 100644 --- a/test/nutrition/nutritional_plan_form_test.dart +++ b/test/nutrition/nutritional_plan_form_test.dart @@ -110,8 +110,11 @@ void main() { await tester.pumpWidget(createHomeScreen(plan2)); await tester.pumpAndSettle(); - expect(find.text(''), findsNWidgets(2), - reason: 'New nutritional plan needs description, and end date'); + expect( + find.text(''), + findsNWidgets(2), + reason: 'New nutritional plan needs description, and end date', + ); // there's also the start date, but it will have a value depending on 'now' await tester.enterText(find.byKey(const Key('field-description')), 'New cool plan'); await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME))); diff --git a/test/nutrition/nutritional_plan_form_test.mocks.dart b/test/nutrition/nutritional_plan_form_test.mocks.dart index 5d42b480..d0200b93 100644 --- a/test/nutrition/nutritional_plan_form_test.mocks.dart +++ b/test/nutrition/nutritional_plan_form_test.mocks.dart @@ -35,9 +35,9 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase { @@ -45,9 +45,9 @@ class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientD Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan { @@ -55,9 +55,9 @@ class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPla Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { @@ -65,9 +65,9 @@ class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { @@ -75,9 +75,9 @@ class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { @@ -85,9 +85,9 @@ class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [NutritionPlansProvider]. @@ -99,173 +99,209 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i3.IngredientDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_1( - this, - Invocation.getter(#database), - ), - ) as _i3.IngredientDatabase); + _i3.IngredientDatabase get database => + (super.noSuchMethod( + Invocation.getter(#database), + returnValue: _FakeIngredientDatabase_1( + this, + Invocation.getter(#database), + ), + ) + as _i3.IngredientDatabase); @override - List<_i7.Ingredient> get ingredients => (super.noSuchMethod( - Invocation.getter(#ingredients), - returnValue: <_i7.Ingredient>[], - ) as List<_i7.Ingredient>); + List<_i7.Ingredient> get ingredients => + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i7.Ingredient>[], + ) + as List<_i7.Ingredient>); @override - List<_i4.NutritionalPlan> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i4.NutritionalPlan>[], - ) as List<_i4.NutritionalPlan>); + List<_i4.NutritionalPlan> get items => + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i4.NutritionalPlan>[], + ) + as List<_i4.NutritionalPlan>); @override set database(_i3.IngredientDatabase? value) => super.noSuchMethod( - Invocation.setter( - #database, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #database, + value, + ), + returnValueForMissingStub: null, + ); @override set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod( - Invocation.setter( - #ingredients, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #ingredients, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i4.NutritionalPlan findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeNutritionalPlan_2( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i4.NutritionalPlan); + _i4.NutritionalPlan findById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findById, + [id], + ), + returnValue: _FakeNutritionalPlan_2( + this, + Invocation.method( + #findById, + [id], + ), + ), + ) + as _i4.NutritionalPlan); @override - _i5.Meal? findMealById(int? id) => (super.noSuchMethod(Invocation.method( - #findMealById, - [id], - )) as _i5.Meal?); + _i5.Meal? findMealById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findMealById, + [id], + ), + ) + as _i5.Meal?); @override - _i9.Future fetchAndSetAllPlansSparse() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansSparse, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetAllPlansSparse() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansSparse, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future fetchAndSetAllPlansFull() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansFull, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetAllPlansFull() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansFull, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> fetchAndSetPlanFull(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future<_i4.NutritionalPlan> addPlan(_i4.NutritionalPlan? planData) => (super.noSuchMethod( - Invocation.method( - #addPlan, - [planData], - ), - returnValue: _i9.Future<_i4.NutritionalPlan>.value(_FakeNutritionalPlan_2( - this, - Invocation.method( - #addPlan, - [planData], - ), - )), - ) as _i9.Future<_i4.NutritionalPlan>); + _i9.Future<_i4.NutritionalPlan> addPlan(_i4.NutritionalPlan? planData) => + (super.noSuchMethod( + Invocation.method( + #addPlan, + [planData], + ), + returnValue: _i9.Future<_i4.NutritionalPlan>.value( + _FakeNutritionalPlan_2( + this, + Invocation.method( + #addPlan, + [planData], + ), + ), + ), + ) + as _i9.Future<_i4.NutritionalPlan>); @override - _i9.Future editPlan(_i4.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #editPlan, - [plan], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future editPlan(_i4.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #editPlan, + [plan], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future deletePlan(int? id) => (super.noSuchMethod( - Invocation.method( - #deletePlan, - [id], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deletePlan(int? id) => + (super.noSuchMethod( + Invocation.method( + #deletePlan, + [id], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i5.Meal> addMeal( @@ -273,49 +309,58 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP int? planId, ) => (super.noSuchMethod( - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - returnValue: _i9.Future<_i5.Meal>.value(_FakeMeal_3( - this, - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - )), - ) as _i9.Future<_i5.Meal>); + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + returnValue: _i9.Future<_i5.Meal>.value( + _FakeMeal_3( + this, + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + ), + ), + ) + as _i9.Future<_i5.Meal>); @override - _i9.Future<_i5.Meal> editMeal(_i5.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #editMeal, - [meal], - ), - returnValue: _i9.Future<_i5.Meal>.value(_FakeMeal_3( - this, - Invocation.method( - #editMeal, - [meal], - ), - )), - ) as _i9.Future<_i5.Meal>); + _i9.Future<_i5.Meal> editMeal(_i5.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #editMeal, + [meal], + ), + returnValue: _i9.Future<_i5.Meal>.value( + _FakeMeal_3( + this, + Invocation.method( + #editMeal, + [meal], + ), + ), + ), + ) + as _i9.Future<_i5.Meal>); @override - _i9.Future deleteMeal(_i5.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #deleteMeal, - [meal], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deleteMeal(_i5.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #deleteMeal, + [meal], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i6.MealItem> addMealItem( @@ -323,44 +368,51 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i5.Meal? meal, ) => (super.noSuchMethod( - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - returnValue: _i9.Future<_i6.MealItem>.value(_FakeMealItem_4( - this, - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - )), - ) as _i9.Future<_i6.MealItem>); + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + returnValue: _i9.Future<_i6.MealItem>.value( + _FakeMealItem_4( + this, + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + ), + ), + ) + as _i9.Future<_i6.MealItem>); @override - _i9.Future deleteMealItem(_i6.MealItem? mealItem) => (super.noSuchMethod( - Invocation.method( - #deleteMealItem, - [mealItem], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future deleteMealItem(_i6.MealItem? mealItem) => + (super.noSuchMethod( + Invocation.method( + #deleteMealItem, + [mealItem], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future clearIngredientCache() => (super.noSuchMethod( - Invocation.method( - #clearIngredientCache, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future clearIngredientCache() => + (super.noSuchMethod( + Invocation.method( + #clearIngredientCache, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future<_i7.Ingredient> fetchIngredient( @@ -368,30 +420,35 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i3.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - returnValue: _i9.Future<_i7.Ingredient>.value(_FakeIngredient_5( - this, - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - )), - ) as _i9.Future<_i7.Ingredient>); + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + returnValue: _i9.Future<_i7.Ingredient>.value( + _FakeIngredient_5( + this, + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + ), + ), + ) + as _i9.Future<_i7.Ingredient>); @override - _i9.Future fetchIngredientsFromCache() => (super.noSuchMethod( - Invocation.method( - #fetchIngredientsFromCache, - [], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchIngredientsFromCache() => + (super.noSuchMethod( + Invocation.method( + #fetchIngredientsFromCache, + [], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future> searchIngredient( @@ -400,25 +457,28 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP bool? searchEnglish = false, }) => (super.noSuchMethod( - Invocation.method( - #searchIngredient, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i9.Future>.value(<_i7.Ingredient>[]), - ) as _i9.Future>); + Invocation.method( + #searchIngredient, + [name], + { + #languageCode: languageCode, + #searchEnglish: searchEnglish, + }, + ), + returnValue: _i9.Future>.value(<_i7.Ingredient>[]), + ) + as _i9.Future>); @override - _i9.Future<_i7.Ingredient?> searchIngredientWithBarcode(String? barcode) => (super.noSuchMethod( - Invocation.method( - #searchIngredientWithBarcode, - [barcode], - ), - returnValue: _i9.Future<_i7.Ingredient?>.value(), - ) as _i9.Future<_i7.Ingredient?>); + _i9.Future<_i7.Ingredient?> searchIngredientWithBarcode(String? barcode) => + (super.noSuchMethod( + Invocation.method( + #searchIngredientWithBarcode, + [barcode], + ), + returnValue: _i9.Future<_i7.Ingredient?>.value(), + ) + as _i9.Future<_i7.Ingredient?>); @override _i9.Future logMealToDiary( @@ -426,16 +486,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? mealDateTime, ) => (super.noSuchMethod( - Invocation.method( - #logMealToDiary, - [ - meal, - mealDateTime, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #logMealToDiary, + [ + meal, + mealDateTime, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future logIngredientToDiary( @@ -444,17 +505,18 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method( - #logIngredientToDiary, - [ - mealItem, - planId, - dateTime, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #logIngredientToDiary, + [ + mealItem, + planId, + dateTime, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override _i9.Future deleteLog( @@ -462,60 +524,63 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP int? planId, ) => (super.noSuchMethod( - Invocation.method( - #deleteLog, - [ - logId, - planId, - ], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + Invocation.method( + #deleteLog, + [ + logId, + planId, + ], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override - _i9.Future fetchAndSetLogs(_i4.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLogs, - [plan], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + _i9.Future fetchAndSetLogs(_i4.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLogs, + [plan], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/nutrition/nutritional_plan_screen_test.mocks.dart b/test/nutrition/nutritional_plan_screen_test.mocks.dart index b9e4f8e5..d5d303df 100644 --- a/test/nutrition/nutritional_plan_screen_test.mocks.dart +++ b/test/nutrition/nutritional_plan_screen_test.mocks.dart @@ -35,9 +35,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -45,9 +45,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -55,9 +55,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -65,9 +65,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i3.StreamedResponse { @@ -75,9 +75,9 @@ class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i3.StreamedRespo Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [WgerBaseProvider]. @@ -89,50 +89,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { } @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -142,46 +148,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i5.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + _i5.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i5.Future>.value([]), + ) + as _i5.Future>); @override _i5.Future> post( @@ -189,15 +200,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future> patch( @@ -205,15 +217,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future<_i3.Response> deleteRequest( @@ -221,24 +234,27 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i5.Future<_i3.Response>); } /// A class which mocks [AuthProvider]. @@ -250,154 +266,174 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { } @override - Map get metadata => (super.noSuchMethod( - Invocation.getter(#metadata), - returnValue: {}, - ) as Map); + Map get metadata => + (super.noSuchMethod( + Invocation.getter(#metadata), + returnValue: {}, + ) + as Map); @override - _i2.AuthState get state => (super.noSuchMethod( - Invocation.getter(#state), - returnValue: _i2.AuthState.updateRequired, - ) as _i2.AuthState); + _i2.AuthState get state => + (super.noSuchMethod( + Invocation.getter(#state), + returnValue: _i2.AuthState.updateRequired, + ) + as _i2.AuthState); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override - bool get dataInit => (super.noSuchMethod( - Invocation.getter(#dataInit), - returnValue: false, - ) as bool); + bool get dataInit => + (super.noSuchMethod( + Invocation.getter(#dataInit), + returnValue: false, + ) + as bool); @override - bool get isAuth => (super.noSuchMethod( - Invocation.getter(#isAuth), - returnValue: false, - ) as bool); + bool get isAuth => + (super.noSuchMethod( + Invocation.getter(#isAuth), + returnValue: false, + ) + as bool); @override set token(String? value) => super.noSuchMethod( - Invocation.setter( - #token, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #token, + value, + ), + returnValueForMissingStub: null, + ); @override set serverUrl(String? value) => super.noSuchMethod( - Invocation.setter( - #serverUrl, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #serverUrl, + value, + ), + returnValueForMissingStub: null, + ); @override set serverVersion(String? value) => super.noSuchMethod( - Invocation.setter( - #serverVersion, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #serverVersion, + value, + ), + returnValueForMissingStub: null, + ); @override set applicationVersion(_i6.PackageInfo? value) => super.noSuchMethod( - Invocation.setter( - #applicationVersion, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #applicationVersion, + value, + ), + returnValueForMissingStub: null, + ); @override set metadata(Map? value) => super.noSuchMethod( - Invocation.setter( - #metadata, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #metadata, + value, + ), + returnValueForMissingStub: null, + ); @override set state(_i2.AuthState? value) => super.noSuchMethod( - Invocation.setter( - #state, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #state, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override set dataInit(bool? value) => super.noSuchMethod( - Invocation.setter( - #dataInit, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #dataInit, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override - _i5.Future setServerVersion() => (super.noSuchMethod( - Invocation.method( - #setServerVersion, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future setServerVersion() => + (super.noSuchMethod( + Invocation.method( + #setServerVersion, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future setApplicationVersion() => (super.noSuchMethod( - Invocation.method( - #setApplicationVersion, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future setApplicationVersion() => + (super.noSuchMethod( + Invocation.method( + #setApplicationVersion, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future initVersions(String? serverUrl) => (super.noSuchMethod( - Invocation.method( - #initVersions, - [serverUrl], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future initVersions(String? serverUrl) => + (super.noSuchMethod( + Invocation.method( + #initVersions, + [serverUrl], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future applicationUpdateRequired([String? version]) => (super.noSuchMethod( - Invocation.method( - #applicationUpdateRequired, - [version], - ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + _i5.Future applicationUpdateRequired([String? version]) => + (super.noSuchMethod( + Invocation.method( + #applicationUpdateRequired, + [version], + ), + returnValue: _i5.Future.value(false), + ) + as _i5.Future); @override _i5.Future<_i2.LoginActions> register({ @@ -408,19 +444,20 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { String? locale = 'en', }) => (super.noSuchMethod( - Invocation.method( - #register, - [], - { - #username: username, - #password: password, - #email: email, - #serverUrl: serverUrl, - #locale: locale, - }, - ), - returnValue: _i5.Future<_i2.LoginActions>.value(_i2.LoginActions.update), - ) as _i5.Future<_i2.LoginActions>); + Invocation.method( + #register, + [], + { + #username: username, + #password: password, + #email: email, + #serverUrl: serverUrl, + #locale: locale, + }, + ), + returnValue: _i5.Future<_i2.LoginActions>.value(_i2.LoginActions.update), + ) + as _i5.Future<_i2.LoginActions>); @override _i5.Future<_i2.LoginActions> login( @@ -430,104 +467,115 @@ class MockAuthProvider extends _i1.Mock implements _i2.AuthProvider { String? apiToken, ) => (super.noSuchMethod( - Invocation.method( - #login, - [ - username, - password, - serverUrl, - apiToken, - ], - ), - returnValue: _i5.Future<_i2.LoginActions>.value(_i2.LoginActions.update), - ) as _i5.Future<_i2.LoginActions>); + Invocation.method( + #login, + [ + username, + password, + serverUrl, + apiToken, + ], + ), + returnValue: _i5.Future<_i2.LoginActions>.value(_i2.LoginActions.update), + ) + as _i5.Future<_i2.LoginActions>); @override - _i5.Future getServerUrlFromPrefs() => (super.noSuchMethod( - Invocation.method( - #getServerUrlFromPrefs, - [], - ), - returnValue: _i5.Future.value(_i7.dummyValue( - this, - Invocation.method( - #getServerUrlFromPrefs, - [], - ), - )), - ) as _i5.Future); + _i5.Future getServerUrlFromPrefs() => + (super.noSuchMethod( + Invocation.method( + #getServerUrlFromPrefs, + [], + ), + returnValue: _i5.Future.value( + _i7.dummyValue( + this, + Invocation.method( + #getServerUrlFromPrefs, + [], + ), + ), + ), + ) + as _i5.Future); @override - _i5.Future tryAutoLogin() => (super.noSuchMethod( - Invocation.method( - #tryAutoLogin, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future tryAutoLogin() => + (super.noSuchMethod( + Invocation.method( + #tryAutoLogin, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future logout({bool? shouldNotify = true}) => (super.noSuchMethod( - Invocation.method( - #logout, - [], - {#shouldNotify: shouldNotify}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future logout({bool? shouldNotify = true}) => + (super.noSuchMethod( + Invocation.method( + #logout, + [], + {#shouldNotify: shouldNotify}, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - String getAppNameHeader() => (super.noSuchMethod( - Invocation.method( - #getAppNameHeader, - [], - ), - returnValue: _i7.dummyValue( - this, - Invocation.method( - #getAppNameHeader, - [], - ), - ), - ) as String); + String getAppNameHeader() => + (super.noSuchMethod( + Invocation.method( + #getAppNameHeader, + [], + ), + returnValue: _i7.dummyValue( + this, + Invocation.method( + #getAppNameHeader, + [], + ), + ), + ) + as String); @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [Client]. @@ -544,20 +592,23 @@ class MockClient extends _i1.Mock implements _i3.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future<_i3.Response> get( @@ -565,20 +616,23 @@ class MockClient extends _i1.Mock implements _i3.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future<_i3.Response> post( @@ -588,28 +642,31 @@ class MockClient extends _i1.Mock implements _i3.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future<_i3.Response> put( @@ -619,28 +676,31 @@ class MockClient extends _i1.Mock implements _i3.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future<_i3.Response> patch( @@ -650,28 +710,31 @@ class MockClient extends _i1.Mock implements _i3.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future<_i3.Response> delete( @@ -681,28 +744,31 @@ class MockClient extends _i1.Mock implements _i3.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i3.Response>); @override _i5.Future read( @@ -710,20 +776,23 @@ class MockClient extends _i1.Mock implements _i3.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future.value(_i7.dummyValue( - this, - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future); + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future.value( + _i7.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future); @override _i5.Future<_i10.Uint8List> readBytes( @@ -731,35 +800,40 @@ class MockClient extends _i1.Mock implements _i3.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)), - ) as _i5.Future<_i10.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)), + ) + as _i5.Future<_i10.Uint8List>); @override - _i5.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) => (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: _i5.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_4( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i5.Future<_i3.StreamedResponse>); + _i5.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: _i5.Future<_i3.StreamedResponse>.value( + _FakeStreamedResponse_4( + this, + Invocation.method( + #send, + [request], + ), + ), + ), + ) + as _i5.Future<_i3.StreamedResponse>); @override void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/nutrition/nutritional_plans_screen_test.dart b/test/nutrition/nutritional_plans_screen_test.dart index 042efd5b..3161ebd0 100644 --- a/test/nutrition/nutritional_plans_screen_test.dart +++ b/test/nutrition/nutritional_plans_screen_test.dart @@ -20,10 +20,8 @@ import 'package:drift/native.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart' as http; -import 'package:intl/intl.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:path/path.dart'; import 'package:provider/provider.dart'; import 'package:wger/database/ingredients/ingredients_database.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; @@ -56,8 +54,9 @@ void main() { }); Widget createHomeScreen({locale = 'en'}) { - when(client.delete(any, headers: anyNamed('headers'))) - .thenAnswer((_) async => http.Response('', 200)); + when( + client.delete(any, headers: anyNamed('headers')), + ).thenAnswer((_) async => http.Response('', 200)); when(mockBaseProvider.deleteRequest(any, any)).thenAnswer( (_) async => http.Response('', 200), @@ -93,15 +92,17 @@ void main() { create: (context) => BodyWeightProvider(mockBaseProvider), ), ChangeNotifierProvider( - create: (context) => UserProvider( - mockBaseProvider, - )..profile = Profile( - username: 'test', - emailVerified: true, - isTrustworthy: true, - email: 'test@example.com', - weightUnitStr: 'kg', - ), + create: (context) => + UserProvider( + mockBaseProvider, + ) + ..profile = Profile( + username: 'test', + emailVerified: true, + isTrustworthy: true, + email: 'test@example.com', + weightUnitStr: 'kg', + ), ), ], child: MaterialApp( @@ -151,14 +152,14 @@ void main() { testWidgets('Tests the localization of dates - EN', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen()); -// note .. "(open ended)" at the time, depending on localisation strings + // note .. "(open ended)" at the time, depending on localisation strings expect(find.textContaining('from 1/1/2021 ('), findsOneWidget); expect(find.textContaining('from 1/10/2021 ('), findsOneWidget); }); testWidgets('Tests the localization of dates - DE', (WidgetTester tester) async { await tester.pumpWidget(createHomeScreen(locale: 'de')); -// note .. "(open ended)" at the time, depending on localisation strings + // note .. "(open ended)" at the time, depending on localisation strings expect(find.textContaining('from 1.1.2021 ('), findsOneWidget); expect(find.textContaining('from 10.1.2021 ('), findsOneWidget); diff --git a/test/nutrition/nutritional_plans_screen_test.mocks.dart b/test/nutrition/nutritional_plans_screen_test.mocks.dart index c1429fd5..cacc127d 100644 --- a/test/nutrition/nutritional_plans_screen_test.mocks.dart +++ b/test/nutrition/nutritional_plans_screen_test.mocks.dart @@ -35,9 +35,9 @@ class _FakeClient_0 extends _i1.SmartFake implements _i2.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeAuthProvider_1 extends _i1.SmartFake implements _i3.AuthProvider { @@ -45,9 +45,9 @@ class _FakeAuthProvider_1 extends _i1.SmartFake implements _i3.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -55,9 +55,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i2.Response { @@ -65,9 +65,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i2.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i2.StreamedResponse { @@ -75,9 +75,9 @@ class _FakeStreamedResponse_4 extends _i1.SmartFake implements _i2.StreamedRespo Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [AuthProvider]. @@ -89,154 +89,174 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { } @override - Map get metadata => (super.noSuchMethod( - Invocation.getter(#metadata), - returnValue: {}, - ) as Map); + Map get metadata => + (super.noSuchMethod( + Invocation.getter(#metadata), + returnValue: {}, + ) + as Map); @override - _i3.AuthState get state => (super.noSuchMethod( - Invocation.getter(#state), - returnValue: _i3.AuthState.updateRequired, - ) as _i3.AuthState); + _i3.AuthState get state => + (super.noSuchMethod( + Invocation.getter(#state), + returnValue: _i3.AuthState.updateRequired, + ) + as _i3.AuthState); @override - _i2.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_0( - this, - Invocation.getter(#client), - ), - ) as _i2.Client); + _i2.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_0( + this, + Invocation.getter(#client), + ), + ) + as _i2.Client); @override - bool get dataInit => (super.noSuchMethod( - Invocation.getter(#dataInit), - returnValue: false, - ) as bool); + bool get dataInit => + (super.noSuchMethod( + Invocation.getter(#dataInit), + returnValue: false, + ) + as bool); @override - bool get isAuth => (super.noSuchMethod( - Invocation.getter(#isAuth), - returnValue: false, - ) as bool); + bool get isAuth => + (super.noSuchMethod( + Invocation.getter(#isAuth), + returnValue: false, + ) + as bool); @override set token(String? value) => super.noSuchMethod( - Invocation.setter( - #token, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #token, + value, + ), + returnValueForMissingStub: null, + ); @override set serverUrl(String? value) => super.noSuchMethod( - Invocation.setter( - #serverUrl, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #serverUrl, + value, + ), + returnValueForMissingStub: null, + ); @override set serverVersion(String? value) => super.noSuchMethod( - Invocation.setter( - #serverVersion, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #serverVersion, + value, + ), + returnValueForMissingStub: null, + ); @override set applicationVersion(_i4.PackageInfo? value) => super.noSuchMethod( - Invocation.setter( - #applicationVersion, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #applicationVersion, + value, + ), + returnValueForMissingStub: null, + ); @override set metadata(Map? value) => super.noSuchMethod( - Invocation.setter( - #metadata, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #metadata, + value, + ), + returnValueForMissingStub: null, + ); @override set state(_i3.AuthState? value) => super.noSuchMethod( - Invocation.setter( - #state, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #state, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i2.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override set dataInit(bool? value) => super.noSuchMethod( - Invocation.setter( - #dataInit, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #dataInit, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override - _i5.Future setServerVersion() => (super.noSuchMethod( - Invocation.method( - #setServerVersion, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future setServerVersion() => + (super.noSuchMethod( + Invocation.method( + #setServerVersion, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future setApplicationVersion() => (super.noSuchMethod( - Invocation.method( - #setApplicationVersion, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future setApplicationVersion() => + (super.noSuchMethod( + Invocation.method( + #setApplicationVersion, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future initVersions(String? serverUrl) => (super.noSuchMethod( - Invocation.method( - #initVersions, - [serverUrl], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future initVersions(String? serverUrl) => + (super.noSuchMethod( + Invocation.method( + #initVersions, + [serverUrl], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future applicationUpdateRequired([String? version]) => (super.noSuchMethod( - Invocation.method( - #applicationUpdateRequired, - [version], - ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + _i5.Future applicationUpdateRequired([String? version]) => + (super.noSuchMethod( + Invocation.method( + #applicationUpdateRequired, + [version], + ), + returnValue: _i5.Future.value(false), + ) + as _i5.Future); @override _i5.Future<_i3.LoginActions> register({ @@ -247,19 +267,20 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { String? locale = 'en', }) => (super.noSuchMethod( - Invocation.method( - #register, - [], - { - #username: username, - #password: password, - #email: email, - #serverUrl: serverUrl, - #locale: locale, - }, - ), - returnValue: _i5.Future<_i3.LoginActions>.value(_i3.LoginActions.update), - ) as _i5.Future<_i3.LoginActions>); + Invocation.method( + #register, + [], + { + #username: username, + #password: password, + #email: email, + #serverUrl: serverUrl, + #locale: locale, + }, + ), + returnValue: _i5.Future<_i3.LoginActions>.value(_i3.LoginActions.update), + ) + as _i5.Future<_i3.LoginActions>); @override _i5.Future<_i3.LoginActions> login( @@ -269,104 +290,115 @@ class MockAuthProvider extends _i1.Mock implements _i3.AuthProvider { String? apiToken, ) => (super.noSuchMethod( - Invocation.method( - #login, - [ - username, - password, - serverUrl, - apiToken, - ], - ), - returnValue: _i5.Future<_i3.LoginActions>.value(_i3.LoginActions.update), - ) as _i5.Future<_i3.LoginActions>); + Invocation.method( + #login, + [ + username, + password, + serverUrl, + apiToken, + ], + ), + returnValue: _i5.Future<_i3.LoginActions>.value(_i3.LoginActions.update), + ) + as _i5.Future<_i3.LoginActions>); @override - _i5.Future getServerUrlFromPrefs() => (super.noSuchMethod( - Invocation.method( - #getServerUrlFromPrefs, - [], - ), - returnValue: _i5.Future.value(_i6.dummyValue( - this, - Invocation.method( - #getServerUrlFromPrefs, - [], - ), - )), - ) as _i5.Future); + _i5.Future getServerUrlFromPrefs() => + (super.noSuchMethod( + Invocation.method( + #getServerUrlFromPrefs, + [], + ), + returnValue: _i5.Future.value( + _i6.dummyValue( + this, + Invocation.method( + #getServerUrlFromPrefs, + [], + ), + ), + ), + ) + as _i5.Future); @override - _i5.Future tryAutoLogin() => (super.noSuchMethod( - Invocation.method( - #tryAutoLogin, - [], - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future tryAutoLogin() => + (super.noSuchMethod( + Invocation.method( + #tryAutoLogin, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future logout({bool? shouldNotify = true}) => (super.noSuchMethod( - Invocation.method( - #logout, - [], - {#shouldNotify: shouldNotify}, - ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + _i5.Future logout({bool? shouldNotify = true}) => + (super.noSuchMethod( + Invocation.method( + #logout, + [], + {#shouldNotify: shouldNotify}, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) + as _i5.Future); @override - String getAppNameHeader() => (super.noSuchMethod( - Invocation.method( - #getAppNameHeader, - [], - ), - returnValue: _i6.dummyValue( - this, - Invocation.method( - #getAppNameHeader, - [], - ), - ), - ) as String); + String getAppNameHeader() => + (super.noSuchMethod( + Invocation.method( + #getAppNameHeader, + [], + ), + returnValue: _i6.dummyValue( + this, + Invocation.method( + #getAppNameHeader, + [], + ), + ), + ) + as String); @override void addListener(_i7.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i7.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [WgerBaseProvider]. @@ -378,50 +410,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider { } @override - _i3.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_1( - this, - Invocation.getter(#auth), - ), - ) as _i3.AuthProvider); + _i3.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_1( + this, + Invocation.getter(#auth), + ), + ) + as _i3.AuthProvider); @override - _i2.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_0( - this, - Invocation.getter(#client), - ), - ) as _i2.Client); + _i2.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_0( + this, + Invocation.getter(#client), + ), + ) + as _i2.Client); @override set auth(_i3.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i2.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -431,46 +469,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i5.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + _i5.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i5.Future>.value([]), + ) + as _i5.Future>); @override _i5.Future> post( @@ -478,15 +521,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future> patch( @@ -494,15 +538,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future<_i2.Response> deleteRequest( @@ -510,24 +555,27 @@ class MockWgerBaseProvider extends _i1.Mock implements _i8.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i5.Future<_i2.Response>); } /// A class which mocks [Client]. @@ -544,20 +592,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> get( @@ -565,20 +616,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> post( @@ -588,28 +642,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> put( @@ -619,28 +676,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> patch( @@ -650,28 +710,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future<_i2.Response> delete( @@ -681,28 +744,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i9.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i5.Future<_i2.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i5.Future<_i2.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i5.Future<_i2.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i5.Future<_i2.Response>); @override _i5.Future read( @@ -710,20 +776,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future.value(_i6.dummyValue( - this, - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - )), - ) as _i5.Future); + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future.value( + _i6.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i5.Future); @override _i5.Future<_i10.Uint8List> readBytes( @@ -731,35 +800,40 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)), - ) as _i5.Future<_i10.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i10.Uint8List>.value(_i10.Uint8List(0)), + ) + as _i5.Future<_i10.Uint8List>); @override - _i5.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: _i5.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_4( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i5.Future<_i2.StreamedResponse>); + _i5.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: _i5.Future<_i2.StreamedResponse>.value( + _FakeStreamedResponse_4( + this, + Invocation.method( + #send, + [request], + ), + ), + ), + ) + as _i5.Future<_i2.StreamedResponse>); @override void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/other/base_provider_test.dart b/test/other/base_provider_test.dart index 3f3376d2..154a0b51 100644 --- a/test/other/base_provider_test.dart +++ b/test/other/base_provider_test.dart @@ -124,12 +124,15 @@ void main() { query: 'limit=20&offset=40', ); - when(mockHttpClient.get(paginationUri1, headers: anyNamed('headers'))) - .thenAnswer((_) => Future.value(response1)); - when(mockHttpClient.get(paginationUri2, headers: anyNamed('headers'))) - .thenAnswer((_) => Future.value(response2)); - when(mockHttpClient.get(paginationUri3, headers: anyNamed('headers'))) - .thenAnswer((_) => Future.value(response3)); + when( + mockHttpClient.get(paginationUri1, headers: anyNamed('headers')), + ).thenAnswer((_) => Future.value(response1)); + when( + mockHttpClient.get(paginationUri2, headers: anyNamed('headers')), + ).thenAnswer((_) => Future.value(response2)); + when( + mockHttpClient.get(paginationUri3, headers: anyNamed('headers')), + ).thenAnswer((_) => Future.value(response3)); // Act final WgerBaseProvider provider = WgerBaseProvider(testAuthProvider, mockHttpClient); diff --git a/test/other/base_provider_test.mocks.dart b/test/other/base_provider_test.mocks.dart index f35c57fb..3cec6689 100644 --- a/test/other/base_provider_test.mocks.dart +++ b/test/other/base_provider_test.mocks.dart @@ -31,9 +31,9 @@ class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeStreamedResponse_1 extends _i1.SmartFake implements _i2.StreamedResponse { @@ -41,9 +41,9 @@ class _FakeStreamedResponse_1 extends _i1.SmartFake implements _i2.StreamedRespo Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [Client]. @@ -60,20 +60,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #head, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #head, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> get( @@ -81,20 +84,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #get, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> post( @@ -104,28 +110,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #post, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #post, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> put( @@ -135,28 +144,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #put, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #put, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> patch( @@ -166,28 +178,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #patch, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #patch, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future<_i2.Response> delete( @@ -197,28 +212,31 @@ class MockClient extends _i1.Mock implements _i2.Client { _i4.Encoding? encoding, }) => (super.noSuchMethod( - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0( - this, - Invocation.method( - #delete, - [url], - { - #headers: headers, - #body: body, - #encoding: encoding, - }, - ), - )), - ) as _i3.Future<_i2.Response>); + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + returnValue: _i3.Future<_i2.Response>.value( + _FakeResponse_0( + this, + Invocation.method( + #delete, + [url], + { + #headers: headers, + #body: body, + #encoding: encoding, + }, + ), + ), + ), + ) + as _i3.Future<_i2.Response>); @override _i3.Future read( @@ -226,20 +244,23 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future.value(_i5.dummyValue( - this, - Invocation.method( - #read, - [url], - {#headers: headers}, - ), - )), - ) as _i3.Future); + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future.value( + _i5.dummyValue( + this, + Invocation.method( + #read, + [url], + {#headers: headers}, + ), + ), + ), + ) + as _i3.Future); @override _i3.Future<_i6.Uint8List> readBytes( @@ -247,35 +268,40 @@ class MockClient extends _i1.Mock implements _i2.Client { Map? headers, }) => (super.noSuchMethod( - Invocation.method( - #readBytes, - [url], - {#headers: headers}, - ), - returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), - ) as _i3.Future<_i6.Uint8List>); + Invocation.method( + #readBytes, + [url], + {#headers: headers}, + ), + returnValue: _i3.Future<_i6.Uint8List>.value(_i6.Uint8List(0)), + ) + as _i3.Future<_i6.Uint8List>); @override - _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => (super.noSuchMethod( - Invocation.method( - #send, - [request], - ), - returnValue: _i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1( - this, - Invocation.method( - #send, - [request], - ), - )), - ) as _i3.Future<_i2.StreamedResponse>); + _i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) => + (super.noSuchMethod( + Invocation.method( + #send, + [request], + ), + returnValue: _i3.Future<_i2.StreamedResponse>.value( + _FakeStreamedResponse_1( + this, + Invocation.method( + #send, + [request], + ), + ), + ), + ) + as _i3.Future<_i2.StreamedResponse>); @override void close() => super.noSuchMethod( - Invocation.method( - #close, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #close, + [], + ), + returnValueForMissingStub: null, + ); } diff --git a/test/routine/forms/session_form_test.dart b/test/routine/forms/session_form_test.dart index 01a90524..53302ea9 100644 --- a/test/routine/forms/session_form_test.dart +++ b/test/routine/forms/session_form_test.dart @@ -131,9 +131,11 @@ void main() { testWidgets('shows server side error messages', (WidgetTester tester) async { // Arrange await pumpSessionForm(tester); - when(mockRoutinesProvider.addSession(any, any)).thenThrow(WgerHttpException.fromMap({ - 'name': ['The name is not valid'], - })); + when(mockRoutinesProvider.addSession(any, any)).thenThrow( + WgerHttpException.fromMap({ + 'name': ['The name is not valid'], + }), + ); // Act await tester.tap(find.byKey(const ValueKey('save-button'))); diff --git a/test/routine/gym_mode_screen_test.dart b/test/routine/gym_mode_screen_test.dart index 0615f4e9..8c332e1f 100644 --- a/test/routine/gym_mode_screen_test.dart +++ b/test/routine/gym_mode_screen_test.dart @@ -60,8 +60,9 @@ void main() { when(mockRoutinesProvider.findRepetitionUnitById(1)).thenReturn(testRepetitionUnit1); when(mockRoutinesProvider.weightUnits).thenReturn(testWeightUnits); when(mockRoutinesProvider.findWeightUnitById(1)).thenReturn(testWeightUnit1); - when(mockRoutinesProvider.fetchAndSetRoutineFull(any)) - .thenAnswer((_) => Future.value(testRoutine)); + when( + mockRoutinesProvider.fetchAndSetRoutineFull(any), + ).thenAnswer((_) => Future.value(testRoutine)); SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); }); @@ -96,10 +97,12 @@ void main() { testWidgets('Test the widgets on the gym mode screen', (WidgetTester tester) async { when(mockExerciseProvider.findExerciseById(1)).thenReturn(testExercises[0]); when(mockExerciseProvider.findExerciseById(6)).thenReturn(testExercises[5]); - when(mockExerciseProvider.findExercisesByVariationId( - null, - exerciseIdToExclude: anyNamed('exerciseIdToExclude'), - )).thenReturn([]); + when( + mockExerciseProvider.findExercisesByVariationId( + null, + exerciseIdToExclude: anyNamed('exerciseIdToExclude'), + ), + ).thenReturn([]); await withClock(Clock.fixed(DateTime(2025, 3, 29, 14, 33)), () async { await tester.pumpWidget(renderGymMode()); diff --git a/test/routine/routine_form_test.dart b/test/routine/routine_form_test.dart index c52c5cd8..8f287f09 100644 --- a/test/routine/routine_form_test.dart +++ b/test/routine/routine_form_test.dart @@ -52,8 +52,9 @@ void main() { mockRoutinesProvider = MockRoutinesProvider(); when(mockRoutinesProvider.findById(any)).thenAnswer((_) => existingRoutine); when(mockRoutinesProvider.editRoutine(any)).thenAnswer((_) => Future.value(existingRoutine)); - when(mockRoutinesProvider.fetchAndSetRoutineFull(any)) - .thenAnswer((_) => Future.value(existingRoutine)); + when( + mockRoutinesProvider.fetchAndSetRoutineFull(any), + ).thenAnswer((_) => Future.value(existingRoutine)); }); Widget renderWidget(Routine routine, {locale = 'en'}) { @@ -115,9 +116,11 @@ void main() { testWidgets('Test editing an existing routine - server error', (WidgetTester tester) async { // Arrange - when(mockRoutinesProvider.editRoutine(any)).thenThrow(WgerHttpException.fromMap({ - 'name': ['The name is not valid'], - })); + when(mockRoutinesProvider.editRoutine(any)).thenThrow( + WgerHttpException.fromMap({ + 'name': ['The name is not valid'], + }), + ); // Act await tester.pumpWidget(renderWidget(existingRoutine)); @@ -185,9 +188,11 @@ void main() { testWidgets('Test creating a new routine - server error', (WidgetTester tester) async { // Arrange - when(mockRoutinesProvider.addRoutine(any)).thenThrow(WgerHttpException.fromMap({ - 'name': ['The name is not valid'], - })); + when(mockRoutinesProvider.addRoutine(any)).thenThrow( + WgerHttpException.fromMap({ + 'name': ['The name is not valid'], + }), + ); // Act await tester.pumpWidget(renderWidget(newRoutine)); diff --git a/test/routine/routines_provider_test.dart b/test/routine/routines_provider_test.dart index 6250415d..4679985c 100644 --- a/test/routine/routines_provider_test.dart +++ b/test/routine/routines_provider_test.dart @@ -58,8 +58,9 @@ void main() { final exercisesProvider = ExercisesProvider(mockBaseProvider); final uri = Uri.https('localhost', 'api/v2/routine/325397/'); - when(mockBaseProvider.makeUrl('routine', id: 325397, query: {'limit': API_MAX_PAGE_SIZE})) - .thenReturn(uri); + when( + mockBaseProvider.makeUrl('routine', id: 325397, query: {'limit': API_MAX_PAGE_SIZE}), + ).thenReturn(uri); when(mockBaseProvider.fetch(uri)).thenAnswer( (_) async => Future.value({ 'id': 325397, @@ -115,8 +116,9 @@ void main() { final uri = Uri.https('localhost', 'api/v2/setting-repetitionunit/'); final tRepetitionUnits = jsonDecode(fixture('routines/repetition_units.json')); when(mockBaseProvider.makeUrl('setting-repetitionunit')).thenReturn(uri); - when(mockBaseProvider.fetchPaginated(uri)) - .thenAnswer((_) => Future.value(tRepetitionUnits['results'])); + when( + mockBaseProvider.fetchPaginated(uri), + ).thenAnswer((_) => Future.value(tRepetitionUnits['results'])); // Load the entries final provider = RoutinesProvider(mockBaseProvider, exercisesProvider, []); @@ -130,8 +132,9 @@ void main() { final uri = Uri.https('localhost', 'api/v2/setting-weightunit/'); when(mockBaseProvider.makeUrl('setting-weightunit')).thenReturn(uri); final tWeightUnits = jsonDecode(fixture('routines/weight_units.json')); - when(mockBaseProvider.fetchPaginated(uri)) - .thenAnswer((_) => Future.value(tWeightUnits['results'])); + when( + mockBaseProvider.fetchPaginated(uri), + ).thenAnswer((_) => Future.value(tWeightUnits['results'])); final ExercisesProvider testExercisesProvider = ExercisesProvider(mockBaseProvider); @@ -148,14 +151,16 @@ void main() { final weightUri = Uri.https('localhost', 'api/v2/setting-weightunit/'); when(mockBaseProvider.makeUrl('setting-weightunit')).thenReturn(weightUri); final tWeightUnits = jsonDecode(fixture('routines/weight_units.json')); - when(mockBaseProvider.fetchPaginated(weightUri)) - .thenAnswer((_) => Future.value(tWeightUnits['results'])); + when( + mockBaseProvider.fetchPaginated(weightUri), + ).thenAnswer((_) => Future.value(tWeightUnits['results'])); final repUnit = Uri.https('localhost', 'api/v2/setting-repetitionunit/'); final tRepetitionUnits = jsonDecode(fixture('routines/repetition_units.json')); when(mockBaseProvider.makeUrl('setting-repetitionunit')).thenReturn(repUnit); - when(mockBaseProvider.fetchPaginated(repUnit)) - .thenAnswer((_) => Future.value(tRepetitionUnits['results'])); + when( + mockBaseProvider.fetchPaginated(repUnit), + ).thenAnswer((_) => Future.value(tRepetitionUnits['results'])); final exercisesProvider = ExercisesProvider(mockBaseProvider); WidgetsFlutterBinding.ensureInitialized(); @@ -176,32 +181,45 @@ void main() { test('Smoke test fetchAndSetRoutineFull', () async { //Arrange final structureUri = Uri.https('localhost', 'api/v2/routine/101/structure/'); - when(mockBaseProvider.makeUrl('routine', objectMethod: 'structure', id: 101)) - .thenReturn(structureUri); - when(mockBaseProvider.fetch(structureUri)).thenAnswer((_) async => Future.value( - jsonDecode(fixture('routines/routine_structure.json')), - )); + when( + mockBaseProvider.makeUrl('routine', objectMethod: 'structure', id: 101), + ).thenReturn(structureUri); + when(mockBaseProvider.fetch(structureUri)).thenAnswer( + (_) async => Future.value( + jsonDecode(fixture('routines/routine_structure.json')), + ), + ); - final dateSequenceDisplayUri = - Uri.https('localhost', 'api/v2/routine/101/date-sequence-display/'); - when(mockBaseProvider.makeUrl('routine', objectMethod: 'date-sequence-display', id: 101)) - .thenReturn(dateSequenceDisplayUri); - when(mockBaseProvider.fetch(dateSequenceDisplayUri)).thenAnswer((_) async => Future.value( - jsonDecode(fixture('routines/routine_date_sequence_display.json')), - )); + final dateSequenceDisplayUri = Uri.https( + 'localhost', + 'api/v2/routine/101/date-sequence-display/', + ); + when( + mockBaseProvider.makeUrl('routine', objectMethod: 'date-sequence-display', id: 101), + ).thenReturn(dateSequenceDisplayUri); + when(mockBaseProvider.fetch(dateSequenceDisplayUri)).thenAnswer( + (_) async => Future.value( + jsonDecode(fixture('routines/routine_date_sequence_display.json')), + ), + ); final dateSequenceGymUri = Uri.https('localhost', 'api/v2/routine/101/date-sequence-gym/'); - when(mockBaseProvider.makeUrl('routine', objectMethod: 'date-sequence-gym', id: 101)) - .thenReturn(dateSequenceGymUri); - when(mockBaseProvider.fetch(dateSequenceGymUri)).thenAnswer((_) async => Future.value( - jsonDecode(fixture('routines/routine_date_sequence_gym.json')), - )); + when( + mockBaseProvider.makeUrl('routine', objectMethod: 'date-sequence-gym', id: 101), + ).thenReturn(dateSequenceGymUri); + when(mockBaseProvider.fetch(dateSequenceGymUri)).thenAnswer( + (_) async => Future.value( + jsonDecode(fixture('routines/routine_date_sequence_gym.json')), + ), + ); final logsUri = Uri.https('localhost', 'api/v2/routine/101/logs/'); when(mockBaseProvider.makeUrl('routine', objectMethod: 'logs', id: 101)).thenReturn(logsUri); - when(mockBaseProvider.fetch(logsUri)).thenAnswer((_) async => Future.value( - jsonDecode(fixture('routines/routine_logs.json')), - )); + when(mockBaseProvider.fetch(logsUri)).thenAnswer( + (_) async => Future.value( + jsonDecode(fixture('routines/routine_logs.json')), + ), + ); final mockExercisesProvider = MockExercisesProvider(); when(mockExercisesProvider.fetchAndSetExercise(76)).thenAnswer( diff --git a/test/user/provider_test.dart b/test/user/provider_test.dart index c9edd0f5..8297b330 100644 --- a/test/user/provider_test.dart +++ b/test/user/provider_test.dart @@ -36,8 +36,9 @@ void main() { late MockWgerBaseProvider mockWgerBaseProvider; const String profileUrl = 'userprofile'; - final Map tUserProfileMap = - jsonDecode(fixture('user/userprofile_response.json')); + final Map tUserProfileMap = jsonDecode( + fixture('user/userprofile_response.json'), + ); final Uri tProfileUri = Uri( scheme: 'http', host: 'localhost', @@ -56,10 +57,12 @@ void main() { userProvider = UserProvider(mockWgerBaseProvider); when(mockWgerBaseProvider.makeUrl(any)).thenReturn(tProfileUri); - when(mockWgerBaseProvider.makeUrl(any, objectMethod: 'verify-email')) - .thenReturn(tEmailVerifyUri); - when(mockWgerBaseProvider.fetch(any)) - .thenAnswer((realInvocation) => Future.value(tUserProfileMap)); + when( + mockWgerBaseProvider.makeUrl(any, objectMethod: 'verify-email'), + ).thenReturn(tEmailVerifyUri); + when( + mockWgerBaseProvider.fetch(any), + ).thenAnswer((realInvocation) => Future.value(tUserProfileMap)); }); group('house keeping', () { diff --git a/test/user/provider_test.mocks.dart b/test/user/provider_test.mocks.dart index 5f3d05d8..e9d11c03 100644 --- a/test/user/provider_test.mocks.dart +++ b/test/user/provider_test.mocks.dart @@ -30,9 +30,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -40,9 +40,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -50,9 +50,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -60,9 +60,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [WgerBaseProvider]. @@ -74,50 +74,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { } @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -127,46 +133,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i5.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + _i5.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i5.Future>.value([]), + ) + as _i5.Future>); @override _i5.Future> post( @@ -174,15 +185,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future> patch( @@ -190,15 +202,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future<_i3.Response> deleteRequest( @@ -206,22 +219,25 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i5.Future<_i3.Response>); } diff --git a/test/utils/errors_test.dart b/test/utils/errors_test.dart index 8f49f0cc..6ec2afb9 100644 --- a/test/utils/errors_test.dart +++ b/test/utils/errors_test.dart @@ -60,7 +60,7 @@ void main() { // Arrange final errors = { 'validation_error': { - 'subkey': ['Error 1', 'Error 2'] + 'subkey': ['Error 1', 'Error 2'], }, }; @@ -78,9 +78,9 @@ void main() { final errors = { 'validation_error': [ { - 'subkey': ['Error 1', 'Error 2'] + 'subkey': ['Error 1', 'Error 2'], }, - {'otherKey': 'foo'} + {'otherKey': 'foo'}, ], }; diff --git a/test/weight/weight_model_test.dart b/test/weight/weight_model_test.dart index ac97ccf6..0bebf456 100644 --- a/test/weight/weight_model_test.dart +++ b/test/weight/weight_model_test.dart @@ -34,8 +34,11 @@ void main() { }); test('Test that the weight entries are correctly converted from json', () { - final WeightEntry weightEntryObj = - WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); + final WeightEntry weightEntryObj = WeightEntry( + id: 1, + weight: 80, + date: DateTime(2020, 12, 31), + ); final WeightEntry weightEntry = WeightEntry.fromJson({ 'id': 1, 'weight': '80', diff --git a/test/weight/weight_provider_test.dart b/test/weight/weight_provider_test.dart index 65938435..72699209 100644 --- a/test/weight/weight_provider_test.dart +++ b/test/weight/weight_provider_test.dart @@ -70,10 +70,12 @@ void main() { path: 'api/v2/weightentry/', ); when(mockBaseProvider.makeUrl(any, query: anyNamed('query'))).thenReturn(uri); - when(mockBaseProvider.post( - {'id': null, 'weight': '80', 'date': '2021-01-01T00:00:00.000'}, - uri, - )).thenAnswer((_) => Future.value({'id': 25, 'date': '2021-01-01', 'weight': '80'})); + when( + mockBaseProvider.post( + {'id': null, 'weight': '80', 'date': '2021-01-01T00:00:00.000'}, + uri, + ), + ).thenAnswer((_) => Future.value({'id': 25, 'date': '2021-01-01', 'weight': '80'})); // Act final BodyWeightProvider provider = BodyWeightProvider(mockBaseProvider); diff --git a/test/weight/weight_provider_test.mocks.dart b/test/weight/weight_provider_test.mocks.dart index 82c4496d..6734a0ad 100644 --- a/test/weight/weight_provider_test.mocks.dart +++ b/test/weight/weight_provider_test.mocks.dart @@ -30,9 +30,9 @@ class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { @@ -40,9 +40,9 @@ class _FakeClient_1 extends _i1.SmartFake implements _i3.Client { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeUri_2 extends _i1.SmartFake implements Uri { @@ -50,9 +50,9 @@ class _FakeUri_2 extends _i1.SmartFake implements Uri { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { @@ -60,9 +60,9 @@ class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [WgerBaseProvider]. @@ -74,50 +74,56 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { } @override - _i2.AuthProvider get auth => (super.noSuchMethod( - Invocation.getter(#auth), - returnValue: _FakeAuthProvider_0( - this, - Invocation.getter(#auth), - ), - ) as _i2.AuthProvider); + _i2.AuthProvider get auth => + (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeAuthProvider_0( + this, + Invocation.getter(#auth), + ), + ) + as _i2.AuthProvider); @override - _i3.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_1( - this, - Invocation.getter(#client), - ), - ) as _i3.Client); + _i3.Client get client => + (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_1( + this, + Invocation.getter(#client), + ), + ) + as _i3.Client); @override set auth(_i2.AuthProvider? value) => super.noSuchMethod( - Invocation.setter( - #auth, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #auth, + value, + ), + returnValueForMissingStub: null, + ); @override set client(_i3.Client? value) => super.noSuchMethod( - Invocation.setter( - #client, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #client, + value, + ), + returnValueForMissingStub: null, + ); @override - Map getDefaultHeaders({bool? includeAuth = false}) => (super.noSuchMethod( - Invocation.method( - #getDefaultHeaders, - [], - {#includeAuth: includeAuth}, - ), - returnValue: {}, - ) as Map); + Map getDefaultHeaders({bool? includeAuth = false}) => + (super.noSuchMethod( + Invocation.method( + #getDefaultHeaders, + [], + {#includeAuth: includeAuth}, + ), + returnValue: {}, + ) + as Map); @override Uri makeUrl( @@ -127,46 +133,51 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Map? query, }) => (super.noSuchMethod( - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - returnValue: _FakeUri_2( - this, - Invocation.method( - #makeUrl, - [path], - { - #id: id, - #objectMethod: objectMethod, - #query: query, - }, - ), - ), - ) as Uri); + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + returnValue: _FakeUri_2( + this, + Invocation.method( + #makeUrl, + [path], + { + #id: id, + #objectMethod: objectMethod, + #query: query, + }, + ), + ), + ) + as Uri); @override - _i5.Future fetch(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetch, - [uri], - ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + _i5.Future fetch(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetch, + [uri], + ), + returnValue: _i5.Future.value(), + ) + as _i5.Future); @override - _i5.Future> fetchPaginated(Uri? uri) => (super.noSuchMethod( - Invocation.method( - #fetchPaginated, - [uri], - ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + _i5.Future> fetchPaginated(Uri? uri) => + (super.noSuchMethod( + Invocation.method( + #fetchPaginated, + [uri], + ), + returnValue: _i5.Future>.value([]), + ) + as _i5.Future>); @override _i5.Future> post( @@ -174,15 +185,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #post, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #post, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future> patch( @@ -190,15 +202,16 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { Uri? uri, ) => (super.noSuchMethod( - Invocation.method( - #patch, - [ - data, - uri, - ], - ), - returnValue: _i5.Future>.value({}), - ) as _i5.Future>); + Invocation.method( + #patch, + [ + data, + uri, + ], + ), + returnValue: _i5.Future>.value({}), + ) + as _i5.Future>); @override _i5.Future<_i3.Response> deleteRequest( @@ -206,22 +219,25 @@ class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider { int? id, ) => (super.noSuchMethod( - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - returnValue: _i5.Future<_i3.Response>.value(_FakeResponse_3( - this, - Invocation.method( - #deleteRequest, - [ - url, - id, - ], - ), - )), - ) as _i5.Future<_i3.Response>); + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + returnValue: _i5.Future<_i3.Response>.value( + _FakeResponse_3( + this, + Invocation.method( + #deleteRequest, + [ + url, + id, + ], + ), + ), + ), + ) + as _i5.Future<_i3.Response>); } diff --git a/test/weight/weight_screen_test.mocks.dart b/test/weight/weight_screen_test.mocks.dart index f0fb8ed9..553ddeae 100644 --- a/test/weight/weight_screen_test.mocks.dart +++ b/test/weight/weight_screen_test.mocks.dart @@ -41,9 +41,9 @@ class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvi Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeWeightEntry_1 extends _i1.SmartFake implements _i3.WeightEntry { @@ -51,9 +51,9 @@ class _FakeWeightEntry_1 extends _i1.SmartFake implements _i3.WeightEntry { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeSharedPreferencesAsync_2 extends _i1.SmartFake implements _i4.SharedPreferencesAsync { @@ -61,9 +61,9 @@ class _FakeSharedPreferencesAsync_2 extends _i1.SmartFake implements _i4.SharedP Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredientDatabase_3 extends _i1.SmartFake implements _i5.IngredientDatabase { @@ -71,9 +71,9 @@ class _FakeIngredientDatabase_3 extends _i1.SmartFake implements _i5.IngredientD Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeNutritionalPlan_4 extends _i1.SmartFake implements _i6.NutritionalPlan { @@ -81,9 +81,9 @@ class _FakeNutritionalPlan_4 extends _i1.SmartFake implements _i6.NutritionalPla Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMeal_5 extends _i1.SmartFake implements _i7.Meal { @@ -91,9 +91,9 @@ class _FakeMeal_5 extends _i1.SmartFake implements _i7.Meal { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeMealItem_6 extends _i1.SmartFake implements _i8.MealItem { @@ -101,9 +101,9 @@ class _FakeMealItem_6 extends _i1.SmartFake implements _i8.MealItem { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } class _FakeIngredient_7 extends _i1.SmartFake implements _i9.Ingredient { @@ -111,9 +111,9 @@ class _FakeIngredient_7 extends _i1.SmartFake implements _i9.Ingredient { Object parent, Invocation parentInvocation, ) : super( - parent, - parentInvocation, - ); + parent, + parentInvocation, + ); } /// A class which mocks [BodyWeightProvider]. @@ -125,144 +125,166 @@ class MockBodyWeightProvider extends _i1.Mock implements _i10.BodyWeightProvider } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - List<_i3.WeightEntry> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i3.WeightEntry>[], - ) as List<_i3.WeightEntry>); + List<_i3.WeightEntry> get items => + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i3.WeightEntry>[], + ) + as List<_i3.WeightEntry>); @override set items(List<_i3.WeightEntry>? entries) => super.noSuchMethod( - Invocation.setter( - #items, - entries, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #items, + entries, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i3.WeightEntry findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeWeightEntry_1( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i3.WeightEntry); + _i3.WeightEntry findById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findById, + [id], + ), + returnValue: _FakeWeightEntry_1( + this, + Invocation.method( + #findById, + [id], + ), + ), + ) + as _i3.WeightEntry); @override - _i3.WeightEntry? findByDate(DateTime? date) => (super.noSuchMethod(Invocation.method( - #findByDate, - [date], - )) as _i3.WeightEntry?); + _i3.WeightEntry? findByDate(DateTime? date) => + (super.noSuchMethod( + Invocation.method( + #findByDate, + [date], + ), + ) + as _i3.WeightEntry?); @override - _i11.Future> fetchAndSetEntries() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetEntries, - [], - ), - returnValue: _i11.Future>.value(<_i3.WeightEntry>[]), - ) as _i11.Future>); + _i11.Future> fetchAndSetEntries() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetEntries, + [], + ), + returnValue: _i11.Future>.value(<_i3.WeightEntry>[]), + ) + as _i11.Future>); @override - _i11.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) => (super.noSuchMethod( - Invocation.method( - #addEntry, - [entry], - ), - returnValue: _i11.Future<_i3.WeightEntry>.value(_FakeWeightEntry_1( - this, - Invocation.method( - #addEntry, - [entry], - ), - )), - ) as _i11.Future<_i3.WeightEntry>); + _i11.Future<_i3.WeightEntry> addEntry(_i3.WeightEntry? entry) => + (super.noSuchMethod( + Invocation.method( + #addEntry, + [entry], + ), + returnValue: _i11.Future<_i3.WeightEntry>.value( + _FakeWeightEntry_1( + this, + Invocation.method( + #addEntry, + [entry], + ), + ), + ), + ) + as _i11.Future<_i3.WeightEntry>); @override - _i11.Future editEntry(_i3.WeightEntry? entry) => (super.noSuchMethod( - Invocation.method( - #editEntry, - [entry], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future editEntry(_i3.WeightEntry? entry) => + (super.noSuchMethod( + Invocation.method( + #editEntry, + [entry], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future deleteEntry(int? id) => (super.noSuchMethod( - Invocation.method( - #deleteEntry, - [id], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future deleteEntry(int? id) => + (super.noSuchMethod( + Invocation.method( + #deleteEntry, + [id], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [UserProvider]. @@ -274,145 +296,159 @@ class MockUserProvider extends _i1.Mock implements _i13.UserProvider { } @override - _i14.ThemeMode get themeMode => (super.noSuchMethod( - Invocation.getter(#themeMode), - returnValue: _i14.ThemeMode.system, - ) as _i14.ThemeMode); + _i14.ThemeMode get themeMode => + (super.noSuchMethod( + Invocation.getter(#themeMode), + returnValue: _i14.ThemeMode.system, + ) + as _i14.ThemeMode); @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i4.SharedPreferencesAsync get prefs => (super.noSuchMethod( - Invocation.getter(#prefs), - returnValue: _FakeSharedPreferencesAsync_2( - this, - Invocation.getter(#prefs), - ), - ) as _i4.SharedPreferencesAsync); + _i4.SharedPreferencesAsync get prefs => + (super.noSuchMethod( + Invocation.getter(#prefs), + returnValue: _FakeSharedPreferencesAsync_2( + this, + Invocation.getter(#prefs), + ), + ) + as _i4.SharedPreferencesAsync); @override set themeMode(_i14.ThemeMode? value) => super.noSuchMethod( - Invocation.setter( - #themeMode, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #themeMode, + value, + ), + returnValueForMissingStub: null, + ); @override set prefs(_i4.SharedPreferencesAsync? value) => super.noSuchMethod( - Invocation.setter( - #prefs, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #prefs, + value, + ), + returnValueForMissingStub: null, + ); @override set profile(_i15.Profile? value) => super.noSuchMethod( - Invocation.setter( - #profile, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #profile, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override void setThemeMode(_i14.ThemeMode? mode) => super.noSuchMethod( - Invocation.method( - #setThemeMode, - [mode], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #setThemeMode, + [mode], + ), + returnValueForMissingStub: null, + ); @override - _i11.Future fetchAndSetProfile() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetProfile, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future fetchAndSetProfile() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetProfile, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future saveProfile() => (super.noSuchMethod( - Invocation.method( - #saveProfile, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future saveProfile() => + (super.noSuchMethod( + Invocation.method( + #saveProfile, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future verifyEmail() => (super.noSuchMethod( - Invocation.method( - #verifyEmail, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future verifyEmail() => + (super.noSuchMethod( + Invocation.method( + #verifyEmail, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [NutritionPlansProvider]. @@ -424,173 +460,209 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans } @override - _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( - Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0( - this, - Invocation.getter(#baseProvider), - ), - ) as _i2.WgerBaseProvider); + _i2.WgerBaseProvider get baseProvider => + (super.noSuchMethod( + Invocation.getter(#baseProvider), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), + ) + as _i2.WgerBaseProvider); @override - _i5.IngredientDatabase get database => (super.noSuchMethod( - Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_3( - this, - Invocation.getter(#database), - ), - ) as _i5.IngredientDatabase); + _i5.IngredientDatabase get database => + (super.noSuchMethod( + Invocation.getter(#database), + returnValue: _FakeIngredientDatabase_3( + this, + Invocation.getter(#database), + ), + ) + as _i5.IngredientDatabase); @override - List<_i9.Ingredient> get ingredients => (super.noSuchMethod( - Invocation.getter(#ingredients), - returnValue: <_i9.Ingredient>[], - ) as List<_i9.Ingredient>); + List<_i9.Ingredient> get ingredients => + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i9.Ingredient>[], + ) + as List<_i9.Ingredient>); @override - List<_i6.NutritionalPlan> get items => (super.noSuchMethod( - Invocation.getter(#items), - returnValue: <_i6.NutritionalPlan>[], - ) as List<_i6.NutritionalPlan>); + List<_i6.NutritionalPlan> get items => + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i6.NutritionalPlan>[], + ) + as List<_i6.NutritionalPlan>); @override set database(_i5.IngredientDatabase? value) => super.noSuchMethod( - Invocation.setter( - #database, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #database, + value, + ), + returnValueForMissingStub: null, + ); @override set ingredients(List<_i9.Ingredient>? value) => super.noSuchMethod( - Invocation.setter( - #ingredients, - value, - ), - returnValueForMissingStub: null, - ); + Invocation.setter( + #ingredients, + value, + ), + returnValueForMissingStub: null, + ); @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); + bool get hasListeners => + (super.noSuchMethod( + Invocation.getter(#hasListeners), + returnValue: false, + ) + as bool); @override void clear() => super.noSuchMethod( - Invocation.method( - #clear, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #clear, + [], + ), + returnValueForMissingStub: null, + ); @override - _i6.NutritionalPlan findById(int? id) => (super.noSuchMethod( - Invocation.method( - #findById, - [id], - ), - returnValue: _FakeNutritionalPlan_4( - this, - Invocation.method( - #findById, - [id], - ), - ), - ) as _i6.NutritionalPlan); + _i6.NutritionalPlan findById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findById, + [id], + ), + returnValue: _FakeNutritionalPlan_4( + this, + Invocation.method( + #findById, + [id], + ), + ), + ) + as _i6.NutritionalPlan); @override - _i7.Meal? findMealById(int? id) => (super.noSuchMethod(Invocation.method( - #findMealById, - [id], - )) as _i7.Meal?); + _i7.Meal? findMealById(int? id) => + (super.noSuchMethod( + Invocation.method( + #findMealById, + [id], + ), + ) + as _i7.Meal?); @override - _i11.Future fetchAndSetAllPlansSparse() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansSparse, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future fetchAndSetAllPlansSparse() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansSparse, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future fetchAndSetAllPlansFull() => (super.noSuchMethod( - Invocation.method( - #fetchAndSetAllPlansFull, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future fetchAndSetAllPlansFull() => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetAllPlansFull, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future<_i6.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - returnValue: _i11.Future<_i6.NutritionalPlan>.value(_FakeNutritionalPlan_4( - this, - Invocation.method( - #fetchAndSetPlanSparse, - [planId], - ), - )), - ) as _i11.Future<_i6.NutritionalPlan>); + _i11.Future<_i6.NutritionalPlan> fetchAndSetPlanSparse(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + returnValue: _i11.Future<_i6.NutritionalPlan>.value( + _FakeNutritionalPlan_4( + this, + Invocation.method( + #fetchAndSetPlanSparse, + [planId], + ), + ), + ), + ) + as _i11.Future<_i6.NutritionalPlan>); @override - _i11.Future<_i6.NutritionalPlan> fetchAndSetPlanFull(int? planId) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - returnValue: _i11.Future<_i6.NutritionalPlan>.value(_FakeNutritionalPlan_4( - this, - Invocation.method( - #fetchAndSetPlanFull, - [planId], - ), - )), - ) as _i11.Future<_i6.NutritionalPlan>); + _i11.Future<_i6.NutritionalPlan> fetchAndSetPlanFull(int? planId) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + returnValue: _i11.Future<_i6.NutritionalPlan>.value( + _FakeNutritionalPlan_4( + this, + Invocation.method( + #fetchAndSetPlanFull, + [planId], + ), + ), + ), + ) + as _i11.Future<_i6.NutritionalPlan>); @override - _i11.Future<_i6.NutritionalPlan> addPlan(_i6.NutritionalPlan? planData) => (super.noSuchMethod( - Invocation.method( - #addPlan, - [planData], - ), - returnValue: _i11.Future<_i6.NutritionalPlan>.value(_FakeNutritionalPlan_4( - this, - Invocation.method( - #addPlan, - [planData], - ), - )), - ) as _i11.Future<_i6.NutritionalPlan>); + _i11.Future<_i6.NutritionalPlan> addPlan(_i6.NutritionalPlan? planData) => + (super.noSuchMethod( + Invocation.method( + #addPlan, + [planData], + ), + returnValue: _i11.Future<_i6.NutritionalPlan>.value( + _FakeNutritionalPlan_4( + this, + Invocation.method( + #addPlan, + [planData], + ), + ), + ), + ) + as _i11.Future<_i6.NutritionalPlan>); @override - _i11.Future editPlan(_i6.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #editPlan, - [plan], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future editPlan(_i6.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #editPlan, + [plan], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future deletePlan(int? id) => (super.noSuchMethod( - Invocation.method( - #deletePlan, - [id], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future deletePlan(int? id) => + (super.noSuchMethod( + Invocation.method( + #deletePlan, + [id], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future<_i7.Meal> addMeal( @@ -598,49 +670,58 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans int? planId, ) => (super.noSuchMethod( - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - returnValue: _i11.Future<_i7.Meal>.value(_FakeMeal_5( - this, - Invocation.method( - #addMeal, - [ - meal, - planId, - ], - ), - )), - ) as _i11.Future<_i7.Meal>); + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + returnValue: _i11.Future<_i7.Meal>.value( + _FakeMeal_5( + this, + Invocation.method( + #addMeal, + [ + meal, + planId, + ], + ), + ), + ), + ) + as _i11.Future<_i7.Meal>); @override - _i11.Future<_i7.Meal> editMeal(_i7.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #editMeal, - [meal], - ), - returnValue: _i11.Future<_i7.Meal>.value(_FakeMeal_5( - this, - Invocation.method( - #editMeal, - [meal], - ), - )), - ) as _i11.Future<_i7.Meal>); + _i11.Future<_i7.Meal> editMeal(_i7.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #editMeal, + [meal], + ), + returnValue: _i11.Future<_i7.Meal>.value( + _FakeMeal_5( + this, + Invocation.method( + #editMeal, + [meal], + ), + ), + ), + ) + as _i11.Future<_i7.Meal>); @override - _i11.Future deleteMeal(_i7.Meal? meal) => (super.noSuchMethod( - Invocation.method( - #deleteMeal, - [meal], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future deleteMeal(_i7.Meal? meal) => + (super.noSuchMethod( + Invocation.method( + #deleteMeal, + [meal], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future<_i8.MealItem> addMealItem( @@ -648,44 +729,51 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans _i7.Meal? meal, ) => (super.noSuchMethod( - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - returnValue: _i11.Future<_i8.MealItem>.value(_FakeMealItem_6( - this, - Invocation.method( - #addMealItem, - [ - mealItem, - meal, - ], - ), - )), - ) as _i11.Future<_i8.MealItem>); + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + returnValue: _i11.Future<_i8.MealItem>.value( + _FakeMealItem_6( + this, + Invocation.method( + #addMealItem, + [ + mealItem, + meal, + ], + ), + ), + ), + ) + as _i11.Future<_i8.MealItem>); @override - _i11.Future deleteMealItem(_i8.MealItem? mealItem) => (super.noSuchMethod( - Invocation.method( - #deleteMealItem, - [mealItem], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future deleteMealItem(_i8.MealItem? mealItem) => + (super.noSuchMethod( + Invocation.method( + #deleteMealItem, + [mealItem], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future clearIngredientCache() => (super.noSuchMethod( - Invocation.method( - #clearIngredientCache, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future clearIngredientCache() => + (super.noSuchMethod( + Invocation.method( + #clearIngredientCache, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future<_i9.Ingredient> fetchIngredient( @@ -693,30 +781,35 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans _i5.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - returnValue: _i11.Future<_i9.Ingredient>.value(_FakeIngredient_7( - this, - Invocation.method( - #fetchIngredient, - [ingredientId], - {#database: database}, - ), - )), - ) as _i11.Future<_i9.Ingredient>); + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + returnValue: _i11.Future<_i9.Ingredient>.value( + _FakeIngredient_7( + this, + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), + ), + ), + ) + as _i11.Future<_i9.Ingredient>); @override - _i11.Future fetchIngredientsFromCache() => (super.noSuchMethod( - Invocation.method( - #fetchIngredientsFromCache, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future fetchIngredientsFromCache() => + (super.noSuchMethod( + Invocation.method( + #fetchIngredientsFromCache, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future> searchIngredient( @@ -725,25 +818,28 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans bool? searchEnglish = false, }) => (super.noSuchMethod( - Invocation.method( - #searchIngredient, - [name], - { - #languageCode: languageCode, - #searchEnglish: searchEnglish, - }, - ), - returnValue: _i11.Future>.value(<_i9.Ingredient>[]), - ) as _i11.Future>); + Invocation.method( + #searchIngredient, + [name], + { + #languageCode: languageCode, + #searchEnglish: searchEnglish, + }, + ), + returnValue: _i11.Future>.value(<_i9.Ingredient>[]), + ) + as _i11.Future>); @override - _i11.Future<_i9.Ingredient?> searchIngredientWithBarcode(String? barcode) => (super.noSuchMethod( - Invocation.method( - #searchIngredientWithBarcode, - [barcode], - ), - returnValue: _i11.Future<_i9.Ingredient?>.value(), - ) as _i11.Future<_i9.Ingredient?>); + _i11.Future<_i9.Ingredient?> searchIngredientWithBarcode(String? barcode) => + (super.noSuchMethod( + Invocation.method( + #searchIngredientWithBarcode, + [barcode], + ), + returnValue: _i11.Future<_i9.Ingredient?>.value(), + ) + as _i11.Future<_i9.Ingredient?>); @override _i11.Future logMealToDiary( @@ -751,16 +847,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans DateTime? mealDateTime, ) => (super.noSuchMethod( - Invocation.method( - #logMealToDiary, - [ - meal, - mealDateTime, - ], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + Invocation.method( + #logMealToDiary, + [ + meal, + mealDateTime, + ], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future logIngredientToDiary( @@ -769,17 +866,18 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method( - #logIngredientToDiary, - [ - mealItem, - planId, - dateTime, - ], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + Invocation.method( + #logIngredientToDiary, + [ + mealItem, + planId, + dateTime, + ], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override _i11.Future deleteLog( @@ -787,60 +885,63 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i16.NutritionPlans int? planId, ) => (super.noSuchMethod( - Invocation.method( - #deleteLog, - [ - logId, - planId, - ], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + Invocation.method( + #deleteLog, + [ + logId, + planId, + ], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override - _i11.Future fetchAndSetLogs(_i6.NutritionalPlan? plan) => (super.noSuchMethod( - Invocation.method( - #fetchAndSetLogs, - [plan], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); + _i11.Future fetchAndSetLogs(_i6.NutritionalPlan? plan) => + (super.noSuchMethod( + Invocation.method( + #fetchAndSetLogs, + [plan], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) + as _i11.Future); @override void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #addListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #removeListener, + [listener], + ), + returnValueForMissingStub: null, + ); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); @override void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method( + #notifyListeners, + [], + ), + returnValueForMissingStub: null, + ); }