In testing, we may want to utilize the existing arg that is used inside of a widget when testing with mocks/overridden providers.
Is there some way/something we can introduce to pass the argument being created with so that when the provider is created, we can override with a different implementation function?
For example, using the number provider:
const numberProvider = Provider.withArgument((context, arg) => arg * 2);
...
testWidgets(..., (...) {
...
ProviderScopeOverride(
overrides:[numberProvider.overrideWithValue((arg) => arg * 4)]
child: ...
);
// Output with numberProvider(1) would be 4, not 2
});
Part of what we are testing could be that the argument provided to it is correct and produces a specific output
In testing, we may want to utilize the existing arg that is used inside of a widget when testing with mocks/overridden providers.
Is there some way/something we can introduce to pass the argument being created with so that when the provider is created, we can override with a different implementation function?
For example, using the number provider:
Part of what we are testing could be that the argument provided to it is correct and produces a specific output