if you want to override the providers. For instance, when you want to test a specific category. In this case, we can override the ScopedProvider with a value. Then, in the ProviderScope, we can choose which provider to override and choose which value to override
testWidgets('Override the current scope', (tester) async {
await tester.pumpWidget(ProviderScope(
overrides: [
selectedCategory.state.overrideWithValue(Category("Pear", Colors.green))
],
child: HookBuilder(builder: (context) {
return MaterialApp(home: CategoryWidget());
})));
expect((tester.firstWidget(find.byType(Text)) as Text).style.color,
Colors.green);
expect((tester.firstWidget(find.byType(Text)) as Text).data, "Pear");
});