-
Notifications
You must be signed in to change notification settings - Fork 29.7k
add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke #147016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
navaronbracke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor docs suggestions while I was reading through it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This sample demonstrates showing how to use PopScopeWithResult to wrap widget that | |
| // This sample demonstrates how to use PopScopeWithResult to wrap a widget that | |
| // may pop the page with a result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // The result contains pop result in `_PageTwo`. | |
| // The result argument contains the pop result that is defined in `_PageTwo`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This is a PopScopeWithResult wrapper over _PageTwoBody | |
| // This is a PopScopeWithResult wrapper over _PageTwoBody. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a void variable feels a bit weird when it happens due to a void API return.
| onPopInvoked: (bool didPop, void result) { | |
| onPopInvoked: (bool didPop, _) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true but we also have avoid anonymous parameter names in the styleguide. I agree that void result is weird, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| onPopInvoked: (bool didPop, void result) { | |
| onPopInvoked: (bool didPop, _) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Justin said we can't do the above, maybe we can get away with Object? result for the void result variables? It's a bit less weird and should work too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Deprecated, use [PopInvokedWithResultCallback] instead | |
| /// Deprecated, use [PopInvokedWithResultCallback] instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing "a" and a slight rewording:
| /// The generic type should match or be supertype of the generic type of the | |
| /// The generic type should match or be a supertype of the generic type of the | |
| /// enclosing [Route]. For example, if the enclosing Route is a `MaterialPageRoute<int>`, | |
| /// you can define [PopScopeWithResult] with `int` or any supertype of `int`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// This sample demonstrates showing how to use PopScope to wrap widget that | |
| /// This sample demonstrates how to use PopScope to wrap a widget that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Holding as Object? instead of T so that PopScopeWithResult in this route can be | |
| // Use Object? instead of T for the generic type of the PopEntry so that PopScopeWithResult in this route can be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This can't be a function getter since dart vm doesn't allow upcasting | |
| // This can't be a function getter since the Dart VM doesn't allow upcasting | |
| // the generic type of a function getter. This prevents users from declaring | |
| // PopScopeWithResult with any generic type that is subtype of ModalRoute._popEntries. |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good, but it's is going to be a contentious change. I'm not sure if there's a way to make that any better, but we should discuss it.
People are already upset about PopScope (see #138614) and this is going to make them even more unhappy, at least at first. Imagine receiving the deprecation warning for WillPopScope, struggling to migrate to PopScope, and then quickly thereafter getting a new deprecation warning for PopScope.
So are there any other options? We could just make a direct breaking change to PopScope without a deprecation by adding the type parameter, as in #139164. But that was reverted (#147015). Can you point to the conversation that lead to the revert?
Anyway, I guess seeing a hard breakage in PopScope might be even worse than a new deprecation warning, so I guess this is what we have to do. Are there any other options we're not thinking of?
And once again I apologize for not including this type parameter in the original PopScope PR 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be an empty line above this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I worry about removing all of the docs on these things and replacing them with just the sentence about deprecation. Can you just leave the docs duplicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart to extend PopScopeWithResult here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you thought about changing these file names to pop_scope_with_result.dart (also the examples)? I guess it's probably overkill, but just wanted to bring it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be child.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true but we also have avoid anonymous parameter names in the styleguide. I agree that void result is weird, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe say "PopScopeWithResult" instead of "pop scope", here and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Since the code being tested doesn't have anything platform specific, and in the course of Flutter's CI process this will end up getting tested on devices of all platforms anyway.
Same for below.
|
Someone reminded me it is against style guide for breaking change. I found this in style guide
I am not sure how strict this should be followed. I am also not a fan of having yet another new widget. The alternative is to not have generic type and then have it always typed as The other alternative is still have the generic type, but deprecate the onPopInvoke and add the onPopInvokeWithResult. note that missing generic type is just a lint error, not a hard breaking change. WDYT? |
|
I guess I will just do the latter, it seems to make the most sense |
5f47550 to
5b5b156
Compare
d0ddfd1 to
404a50a
Compare
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits 👍
I agree that the current approach seems to be the best option for minimizing pains related to breaking changes. I can't think of anything better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe add a message here, in case someone didn't see the deprecation error? "onPopInvoked is deprecated, use onPopWithResultInvoked"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe onPopInvokedWithResult is a better name? Up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this doesn't have any other implications in this PR, does it? Like I seem to see PopEntry is still being used in the same way.
404a50a to
9af5a27
Compare
)" (flutter#147015)" This reverts commit bb4c9b3.
Co-authored-by: Navaron Bracke <[email protected]>
9af5a27 to
3a1c032
Compare
…pScope.onPopInvoke (flutter/flutter#147016)
flutter/flutter@5d3bca4...2e80670 2024-04-26 [email protected] Roll Flutter Engine from d79458007712 to c410180e5bba (1 revision) (flutter/flutter#147407) 2024-04-26 [email protected] Roll Flutter Engine from 11a857e1599f to d79458007712 (1 revision) (flutter/flutter#147401) 2024-04-26 [email protected] Roll Flutter Engine from e99fc6ef91ef to 11a857e1599f (4 revisions) (flutter/flutter#147399) 2024-04-26 [email protected] Fix `FloatingActionButton` docs for `background` and `foreground` properties (flutter/flutter#147372) 2024-04-26 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.4 to 6.0.5 (flutter/flutter#147388) 2024-04-26 [email protected] Fix `DateRangePickerDialog` does not use `rangePickerHeaderBackgroundColor` from `DatePickerTheme` in M2 (flutter/flutter#147370) 2024-04-26 [email protected] Roll Flutter Engine from a09295fe03c0 to e99fc6ef91ef (4 revisions) (flutter/flutter#147391) 2024-04-26 [email protected] Clean up leaks in a test. (flutter/flutter#147312) 2024-04-26 [email protected] add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (flutter/flutter#147016) 2024-04-26 [email protected] zero-sized RenderConstraintsTransformBox respects clipBehavior (flutter/flutter#147349) 2024-04-25 [email protected] Roll Flutter Engine from 3768ca0c02da to a09295fe03c0 (1 revision) (flutter/flutter#147386) 2024-04-25 [email protected] [devicelab] explicitly enable vulkan validation in test. (flutter/flutter#147382) 2024-04-25 [email protected] Roll Flutter Engine from 10a3504a9261 to 3768ca0c02da (1 revision) (flutter/flutter#147381) 2024-04-25 [email protected] Roll Flutter Engine from 694756b875bf to 10a3504a9261 (3 revisions) (flutter/flutter#147380) 2024-04-25 [email protected] Roll Flutter Engine from 19c182f47bde to 694756b875bf (1 revision) (flutter/flutter#147379) 2024-04-25 [email protected] Roll Flutter Engine from 163c18e870a9 to 19c182f47bde (1 revision) (flutter/flutter#147378) 2024-04-25 [email protected] Makes badge to auto size with content (flutter/flutter#146853) 2024-04-25 [email protected] Fix memory leaks in `Hero` widget (flutter/flutter#147303) 2024-04-25 [email protected] Roll Packages from cf6d280 to fde908d (11 revisions) (flutter/flutter#147375) 2024-04-25 [email protected] Roll Flutter Engine from 674890ce7141 to 163c18e870a9 (1 revision) (flutter/flutter#147373) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
|
Time to revert pull request flutter/flutter/147016 has elapsed. |
|
https://github.com/ethanblake4/flutter_eval needs to be migrated in order to roll this change into internal code base |
…pScope.onPopInvoke (flutter#147016)" This reverts commit 8031a3e.
#147597) …pScope.onPopInvoke (#147016)" This reverts commit 8031a3e. Needs to migrate flutter_eval ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
flutter#147597) …pScope.onPopInvoke (flutter#147016)" This reverts commit 8031a3e. Needs to migrate flutter_eval ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
flutter/flutter@5d3bca4...2e80670 2024-04-26 [email protected] Roll Flutter Engine from d79458007712 to c410180e5bba (1 revision) (flutter/flutter#147407) 2024-04-26 [email protected] Roll Flutter Engine from 11a857e1599f to d79458007712 (1 revision) (flutter/flutter#147401) 2024-04-26 [email protected] Roll Flutter Engine from e99fc6ef91ef to 11a857e1599f (4 revisions) (flutter/flutter#147399) 2024-04-26 [email protected] Fix `FloatingActionButton` docs for `background` and `foreground` properties (flutter/flutter#147372) 2024-04-26 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.4 to 6.0.5 (flutter/flutter#147388) 2024-04-26 [email protected] Fix `DateRangePickerDialog` does not use `rangePickerHeaderBackgroundColor` from `DatePickerTheme` in M2 (flutter/flutter#147370) 2024-04-26 [email protected] Roll Flutter Engine from a09295fe03c0 to e99fc6ef91ef (4 revisions) (flutter/flutter#147391) 2024-04-26 [email protected] Clean up leaks in a test. (flutter/flutter#147312) 2024-04-26 [email protected] add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (flutter/flutter#147016) 2024-04-26 [email protected] zero-sized RenderConstraintsTransformBox respects clipBehavior (flutter/flutter#147349) 2024-04-25 [email protected] Roll Flutter Engine from 3768ca0c02da to a09295fe03c0 (1 revision) (flutter/flutter#147386) 2024-04-25 [email protected] [devicelab] explicitly enable vulkan validation in test. (flutter/flutter#147382) 2024-04-25 [email protected] Roll Flutter Engine from 10a3504a9261 to 3768ca0c02da (1 revision) (flutter/flutter#147381) 2024-04-25 [email protected] Roll Flutter Engine from 694756b875bf to 10a3504a9261 (3 revisions) (flutter/flutter#147380) 2024-04-25 [email protected] Roll Flutter Engine from 19c182f47bde to 694756b875bf (1 revision) (flutter/flutter#147379) 2024-04-25 [email protected] Roll Flutter Engine from 163c18e870a9 to 19c182f47bde (1 revision) (flutter/flutter#147378) 2024-04-25 [email protected] Makes badge to auto size with content (flutter/flutter#146853) 2024-04-25 [email protected] Fix memory leaks in `Hero` widget (flutter/flutter#147303) 2024-04-25 [email protected] Roll Packages from cf6d280 to fde908d (11 revisions) (flutter/flutter#147375) 2024-04-25 [email protected] Roll Flutter Engine from 674890ce7141 to 163c18e870a9 (1 revision) (flutter/flutter#147373) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…pScope.onPopInvoke (flutter/flutter#147016)
|
I'm not sure if this is the best place to ask this, but maybe the docs for migrating a back confirmation dialog could be updated to avoid the use of the now-deprecated |
same as #139164, but make it a soft transition
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.