Add overrideWithFunction to ArgProvider for dynamic test overrides#36
Add overrideWithFunction to ArgProvider for dynamic test overrides#36
overrideWithFunction to ArgProvider for dynamic test overrides#36Conversation
Co-authored-by: nank1ro <60045235+nank1ro@users.noreply.github.com>
overrideWithFunction to ArgProvider for dynamic test overrides
Provider Benchmark ResultsDate: 2026-03-02 10:45:30 UTC Results
|
|
@copilot remove resetOverride, it is not needed at all. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #36 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 288 288
=========================================
Hits 288 288
🚀 New features to boost your workflow:
|
Co-authored-by: nank1ro <60045235+nank1ro@users.noreply.github.com>
|
@copilot bump the version in pubspec.yaml and update the CHANGELOG.md accordingly |
Co-authored-by: nank1ro <60045235+nank1ro@users.noreply.github.com>
|
@nank1ro I think we need to have version 2.1.0 instead of 1.0.0 in https://disco.mariuti.com/installing/. Also, do we have to add disco_lint under the dev dependencies in the pubspec.yaml? |
No, disco_lint needs to be present only in the |
Deploying flutter-disco with
|
| Latest commit: |
0daf85a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://42f2ff4b.flutter-disco.pages.dev |
| Branch Preview URL: | https://copilot-allow-dynamic-overri.flutter-disco.pages.dev |
|
Pretty sure this implementation is not adequate. You probably want the provider to stay immutable. It should be more similar to: and |
I intentionally said to copilot to do it in this way for two reasons:
If we use an PS: What I'm saying here is because I've already tried locally with an Agent to do what you've proposed. This was my first idea but it comes with a lot of complexity and many code changes needed |
Remember that providers and argument providers are just identifiers. A matching Probable kind of bug (I did not test it, so I might be wrong): // Note: numberProvider is ((arg) => arg * 2) and lazy
testWidgets(..., (...) {
ProviderScope(
providers: [numberProvider(2)]
child: ...
List [
// somehow this is run first
ProviderScopeOverride(
overrides:[numberProvider.overrideWithFunction((arg) => arg * 4)]
child: ...
),
// ensure that the following is run second, after the override. Maybe some lazy screen or something like that.
OtherWidget(inject numberProvider here...)
]
)
});Problem: Inside For the same reason, also this kind of structure probably won't work. // Note: numberProvider is ((arg) => arg * 2) and it can be either lazy or strict
testWidgets(..., (...) {
List [
// somehow this is run first
ProviderScopeOverride(
overrides:[numberProvider.overrideWithFunction((arg) => arg * 4)]
child: ...
),
// ensure that the following is run second, after the override. Maybe some lazy screen or something like that.
ProviderScope(
providers: [numberProvider(2)]
child: OtherWidget(inject numberProvider here...) // value will be 8 instead of 4
)
]
});Can you add such tests, so we can test my hypothesis? |
|
Let's not rush this PR. I have much more important priorities until the 20th of March. I will review it after that date. You can continue working on this and, once more or less ready, offer a way to test this branch in #35. |
|
@copilot given the comment made by manuel Can you add the required tests he mentioned? |
... Your comment appears to be cut off after |
No idea what do you mean in the following content. overrideWithValue takes a T value, it is not a function that gives the argument. That's why the user opened the issue. |
|
I meant Edit: I updated it in #36 (comment) |
@immutableannotation fromArgProvider_overrideFnfield toArgProvideroverrideWithFunctionmethod toArgProvider_generateIntermediateProviderto use_overrideFn ?? _createValueoverrideWithFunction(basic override, arg forwarding)resetOverridemethod and its test per review feedbackOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.