Merge pull request #978 from lenka369/master

Save ingredient to cache on selection
This commit is contained in:
Roland Geider
2025-11-19 16:38:35 +01:00
committed by GitHub
6 changed files with 301 additions and 76 deletions

View File

@@ -302,6 +302,37 @@ class NutritionPlansProvider with ChangeNotifier {
await database.deleteEverything();
}
/// Saves an ingredient to the cache
Future<void> cacheIngredient(Ingredient ingredient, {IngredientDatabase? database}) async {
database ??= this.database;
if (!ingredients.any((e) => e.id == ingredient.id)) {
ingredients.add(ingredient);
}
final ingredientDb = await (database.select(
database.ingredients,
)..where((e) => e.id.equals(ingredient.id))).getSingleOrNull();
if (ingredientDb == null) {
final data = ingredient.toJson();
try {
await database
.into(database.ingredients)
.insert(
IngredientsCompanion.insert(
id: ingredient.id,
data: jsonEncode(data),
lastFetched: DateTime.now(),
),
);
_logger.finer("Saved ingredient '${ingredient.name}' to db cache");
} catch (e) {
_logger.finer("Error caching ingredient '${ingredient.name}': $e");
}
}
}
/// Fetch and return an ingredient
///
/// If the ingredient is not known locally, it is fetched from the server
@@ -329,22 +360,14 @@ class NutritionPlansProvider with ChangeNotifier {
(database.delete(database.ingredients)..where((i) => i.id.equals(ingredientId))).go();
}
} else {
_logger.info("Fetching ingredient ID $ingredientId from server");
final data = await baseProvider.fetch(
baseProvider.makeUrl(_ingredientInfoPath, id: ingredientId),
);
ingredient = Ingredient.fromJson(data);
ingredients.add(ingredient);
database
.into(database.ingredients)
.insert(
IngredientsCompanion.insert(
id: ingredientId,
data: jsonEncode(data),
lastFetched: DateTime.now(),
),
);
_logger.finer("Saved ingredient '${ingredient.name}' to db cache");
// Cache the ingredient
await cacheIngredient(ingredient, database: database);
}
}
@@ -376,6 +399,7 @@ class NutritionPlansProvider with ChangeNotifier {
}
// Send the request
_logger.info("Fetching ingredients from server");
final response = await baseProvider.fetch(
baseProvider.makeUrl(
_ingredientInfoPath,
@@ -406,6 +430,7 @@ class NutritionPlansProvider with ChangeNotifier {
if (data['count'] == 0) {
return null;
}
// TODO we should probably add it to ingredient cache.
return Ingredient.fromJson(data['results'][0]);
}

View File

@@ -184,7 +184,10 @@ class _IngredientTypeaheadState extends State<IngredientTypeahead> {
opacity: CurvedAnimation(parent: animation, curve: Curves.fastOutSlowIn),
child: child,
),
onSelected: (suggestion) {
onSelected: (suggestion) async {
// Cache selected ingredient
final provider = Provider.of<NutritionPlansProvider>(context, listen: false);
await provider.cacheIngredient(suggestion);
widget.selectIngredient(suggestion.id, suggestion.name, null);
},
),

View File

@@ -207,11 +207,13 @@ void main() {
description: 'Old active plan',
startDate: now.subtract(const Duration(days: 10)),
endDate: now.add(const Duration(days: 10)),
creationDate: now.subtract(const Duration(days: 10)),
);
final newerPlan = NutritionalPlan(
description: 'Newer active plan',
startDate: now.subtract(const Duration(days: 5)),
endDate: now.add(const Duration(days: 5)),
creationDate: now.subtract(const Duration(days: 1)),
);
nutritionProvider = NutritionPlansProvider(mockWgerBaseProvider, [
olderPlan,
@@ -222,6 +224,19 @@ void main() {
});
group('Ingredient cache DB', () {
test('cacheIngredient saves to both in-memory and database cache', () async {
nutritionProvider.ingredients = [];
final ingredient = Ingredient.fromJson(ingredient59887Response);
await nutritionProvider.cacheIngredient(ingredient, database: database);
expect(nutritionProvider.ingredients.length, 1);
expect(nutritionProvider.ingredients.first.id, 59887);
final rows = await database.select(database.ingredients).get();
expect(rows.length, 1);
expect(rows.first.id, ingredient.id);
});
test('that if there is already valid data in the DB, the API is not hit', () async {
// Arrange
nutritionProvider.ingredients = [];

View File

@@ -30,37 +30,44 @@ import 'package:wger/providers/nutrition.dart' as _i8;
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
implements _i2.WgerBaseProvider {
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase {
class _FakeIngredientDatabase_1 extends _i1.SmartFake
implements _i3.IngredientDatabase {
_FakeIngredientDatabase_1(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan {
class _FakeNutritionalPlan_2 extends _i1.SmartFake
implements _i4.NutritionalPlan {
_FakeNutritionalPlan_2(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal {
_FakeMeal_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeMeal_3(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem {
_FakeMealItem_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeMealItem_4(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient {
_FakeIngredient_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeIngredient_5(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
/// A class which mocks [NutritionPlansProvider].
///
/// See the documentation for Mockito's code generation for more information.
class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansProvider {
class MockNutritionPlansProvider extends _i1.Mock
implements _i8.NutritionPlansProvider {
MockNutritionPlansProvider() {
_i1.throwOnMissingStub(this);
}
@@ -69,7 +76,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
_i2.WgerBaseProvider get baseProvider =>
(super.noSuchMethod(
Invocation.getter(#baseProvider),
returnValue: _FakeWgerBaseProvider_0(this, Invocation.getter(#baseProvider)),
returnValue: _FakeWgerBaseProvider_0(
this,
Invocation.getter(#baseProvider),
),
)
as _i2.WgerBaseProvider);
@@ -77,41 +87,60 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
_i3.IngredientDatabase get database =>
(super.noSuchMethod(
Invocation.getter(#database),
returnValue: _FakeIngredientDatabase_1(this, 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>[])
(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>[])
(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);
set database(_i3.IngredientDatabase? value) => super.noSuchMethod(
Invocation.setter(#database, value),
returnValueForMissingStub: null,
);
@override
set ingredients(List<_i7.Ingredient>? value) =>
super.noSuchMethod(Invocation.setter(#ingredients, value), returnValueForMissingStub: null);
set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod(
Invocation.setter(#ingredients, value),
returnValueForMissingStub: null,
);
@override
bool get hasListeners =>
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false)
as bool);
@override
void clear() =>
super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null);
void clear() => super.noSuchMethod(
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])),
returnValue: _FakeNutritionalPlan_2(
this,
Invocation.method(#findById, [id]),
),
)
as _i4.NutritionalPlan);
@@ -142,7 +171,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#fetchAndSetPlanSparse, [planId]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanSparse, [planId])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#fetchAndSetPlanSparse, [planId]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -152,7 +184,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#fetchAndSetPlanFull, [planId]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanFull, [planId])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#fetchAndSetPlanFull, [planId]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -162,7 +197,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#addPlan, [planData]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#addPlan, [planData])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#addPlan, [planData]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -215,11 +253,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
as _i9.Future<void>);
@override
_i9.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, _i5.Meal? meal) =>
_i9.Future<_i6.MealItem> addMealItem(
_i6.MealItem? mealItem,
_i5.Meal? meal,
) =>
(super.noSuchMethod(
Invocation.method(#addMealItem, [mealItem, meal]),
returnValue: _i9.Future<_i6.MealItem>.value(
_FakeMealItem_4(this, Invocation.method(#addMealItem, [mealItem, meal])),
_FakeMealItem_4(
this,
Invocation.method(#addMealItem, [mealItem, meal]),
),
),
)
as _i9.Future<_i6.MealItem>);
@@ -242,17 +286,41 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
)
as _i9.Future<void>);
@override
_i9.Future<void> cacheIngredient(
_i7.Ingredient? ingredient, {
_i3.IngredientDatabase? database,
}) =>
(super.noSuchMethod(
Invocation.method(
#cacheIngredient,
[ingredient],
{#database: database},
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
)
as _i9.Future<void>);
@override
_i9.Future<_i7.Ingredient> fetchIngredient(
int? ingredientId, {
_i3.IngredientDatabase? database,
}) =>
(super.noSuchMethod(
Invocation.method(#fetchIngredient, [ingredientId], {#database: database}),
Invocation.method(
#fetchIngredient,
[ingredientId],
{#database: database},
),
returnValue: _i9.Future<_i7.Ingredient>.value(
_FakeIngredient_5(
this,
Invocation.method(#fetchIngredient, [ingredientId], {#database: database}),
Invocation.method(
#fetchIngredient,
[ingredientId],
{#database: database},
),
),
),
)
@@ -279,7 +347,9 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
[name],
{#languageCode: languageCode, #searchEnglish: searchEnglish},
),
returnValue: _i9.Future<List<_i7.Ingredient>>.value(<_i7.Ingredient>[]),
returnValue: _i9.Future<List<_i7.Ingredient>>.value(
<_i7.Ingredient>[],
),
)
as _i9.Future<List<_i7.Ingredient>>);
@@ -307,7 +377,11 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
DateTime? dateTime,
]) =>
(super.noSuchMethod(
Invocation.method(#logIngredientToDiary, [mealItem, planId, dateTime]),
Invocation.method(#logIngredientToDiary, [
mealItem,
planId,
dateTime,
]),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
)
@@ -344,10 +418,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
);
@override
void dispose() =>
super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null);
void dispose() => super.noSuchMethod(
Invocation.method(#dispose, []),
returnValueForMissingStub: null,
);
@override
void notifyListeners() =>
super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null);
void notifyListeners() => super.noSuchMethod(
Invocation.method(#notifyListeners, []),
returnValueForMissingStub: null,
);
}

View File

@@ -331,5 +331,31 @@ void main() {
verify(mockNutrition.addMealItem(any, meal1));
},
);
testWidgets('selecting ingredient from autocomplete calls cacheIngredient', (
WidgetTester tester,
) async {
await tester.pumpWidget(createMealItemFormScreen(meal1, '', true));
await tester.pumpAndSettle();
clearInteractions(mockNutrition);
when(
mockNutrition.searchIngredient(
any,
languageCode: anyNamed('languageCode'),
searchEnglish: anyNamed('searchEnglish'),
),
).thenAnswer((_) => Future.value([ingredient1]));
await tester.enterText(find.byType(TextFormField).first, 'Water');
await tester.pumpAndSettle(const Duration(milliseconds: 600));
await tester.pumpAndSettle();
await tester.tap(find.byType(ListTile).first);
await tester.pumpAndSettle();
verify(mockNutrition.cacheIngredient(ingredient1)).called(1);
});
});
}

View File

@@ -30,37 +30,44 @@ import 'package:wger/providers/nutrition.dart' as _i8;
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
class _FakeWgerBaseProvider_0 extends _i1.SmartFake
implements _i2.WgerBaseProvider {
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase {
class _FakeIngredientDatabase_1 extends _i1.SmartFake
implements _i3.IngredientDatabase {
_FakeIngredientDatabase_1(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan {
class _FakeNutritionalPlan_2 extends _i1.SmartFake
implements _i4.NutritionalPlan {
_FakeNutritionalPlan_2(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal {
_FakeMeal_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeMeal_3(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem {
_FakeMealItem_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeMealItem_4(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient {
_FakeIngredient_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
_FakeIngredient_5(Object parent, Invocation parentInvocation)
: super(parent, parentInvocation);
}
/// A class which mocks [NutritionPlansProvider].
///
/// See the documentation for Mockito's code generation for more information.
class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansProvider {
class MockNutritionPlansProvider extends _i1.Mock
implements _i8.NutritionPlansProvider {
MockNutritionPlansProvider() {
_i1.throwOnMissingStub(this);
}
@@ -69,7 +76,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
_i2.WgerBaseProvider get baseProvider =>
(super.noSuchMethod(
Invocation.getter(#baseProvider),
returnValue: _FakeWgerBaseProvider_0(this, Invocation.getter(#baseProvider)),
returnValue: _FakeWgerBaseProvider_0(
this,
Invocation.getter(#baseProvider),
),
)
as _i2.WgerBaseProvider);
@@ -77,41 +87,60 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
_i3.IngredientDatabase get database =>
(super.noSuchMethod(
Invocation.getter(#database),
returnValue: _FakeIngredientDatabase_1(this, 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>[])
(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>[])
(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);
set database(_i3.IngredientDatabase? value) => super.noSuchMethod(
Invocation.setter(#database, value),
returnValueForMissingStub: null,
);
@override
set ingredients(List<_i7.Ingredient>? value) =>
super.noSuchMethod(Invocation.setter(#ingredients, value), returnValueForMissingStub: null);
set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod(
Invocation.setter(#ingredients, value),
returnValueForMissingStub: null,
);
@override
bool get hasListeners =>
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false)
as bool);
@override
void clear() =>
super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null);
void clear() => super.noSuchMethod(
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])),
returnValue: _FakeNutritionalPlan_2(
this,
Invocation.method(#findById, [id]),
),
)
as _i4.NutritionalPlan);
@@ -142,7 +171,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#fetchAndSetPlanSparse, [planId]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanSparse, [planId])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#fetchAndSetPlanSparse, [planId]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -152,7 +184,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#fetchAndSetPlanFull, [planId]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanFull, [planId])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#fetchAndSetPlanFull, [planId]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -162,7 +197,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
(super.noSuchMethod(
Invocation.method(#addPlan, [planData]),
returnValue: _i9.Future<_i4.NutritionalPlan>.value(
_FakeNutritionalPlan_2(this, Invocation.method(#addPlan, [planData])),
_FakeNutritionalPlan_2(
this,
Invocation.method(#addPlan, [planData]),
),
),
)
as _i9.Future<_i4.NutritionalPlan>);
@@ -215,11 +253,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
as _i9.Future<void>);
@override
_i9.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, _i5.Meal? meal) =>
_i9.Future<_i6.MealItem> addMealItem(
_i6.MealItem? mealItem,
_i5.Meal? meal,
) =>
(super.noSuchMethod(
Invocation.method(#addMealItem, [mealItem, meal]),
returnValue: _i9.Future<_i6.MealItem>.value(
_FakeMealItem_4(this, Invocation.method(#addMealItem, [mealItem, meal])),
_FakeMealItem_4(
this,
Invocation.method(#addMealItem, [mealItem, meal]),
),
),
)
as _i9.Future<_i6.MealItem>);
@@ -242,17 +286,41 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
)
as _i9.Future<void>);
@override
_i9.Future<void> cacheIngredient(
_i7.Ingredient? ingredient, {
_i3.IngredientDatabase? database,
}) =>
(super.noSuchMethod(
Invocation.method(
#cacheIngredient,
[ingredient],
{#database: database},
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
)
as _i9.Future<void>);
@override
_i9.Future<_i7.Ingredient> fetchIngredient(
int? ingredientId, {
_i3.IngredientDatabase? database,
}) =>
(super.noSuchMethod(
Invocation.method(#fetchIngredient, [ingredientId], {#database: database}),
Invocation.method(
#fetchIngredient,
[ingredientId],
{#database: database},
),
returnValue: _i9.Future<_i7.Ingredient>.value(
_FakeIngredient_5(
this,
Invocation.method(#fetchIngredient, [ingredientId], {#database: database}),
Invocation.method(
#fetchIngredient,
[ingredientId],
{#database: database},
),
),
),
)
@@ -279,7 +347,9 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
[name],
{#languageCode: languageCode, #searchEnglish: searchEnglish},
),
returnValue: _i9.Future<List<_i7.Ingredient>>.value(<_i7.Ingredient>[]),
returnValue: _i9.Future<List<_i7.Ingredient>>.value(
<_i7.Ingredient>[],
),
)
as _i9.Future<List<_i7.Ingredient>>);
@@ -307,7 +377,11 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
DateTime? dateTime,
]) =>
(super.noSuchMethod(
Invocation.method(#logIngredientToDiary, [mealItem, planId, dateTime]),
Invocation.method(#logIngredientToDiary, [
mealItem,
planId,
dateTime,
]),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),
)
@@ -344,10 +418,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP
);
@override
void dispose() =>
super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null);
void dispose() => super.noSuchMethod(
Invocation.method(#dispose, []),
returnValueForMissingStub: null,
);
@override
void notifyListeners() =>
super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null);
void notifyListeners() => super.noSuchMethod(
Invocation.method(#notifyListeners, []),
returnValueForMissingStub: null,
);
}