Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Apr 18, 2024

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.

@chunhtai chunhtai requested a review from justinmc April 18, 2024 22:57
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: routes Navigator, Router, and related APIs. labels Apr 18, 2024
Copy link
Contributor

@navaronbracke navaronbracke left a 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The result contains pop result in `_PageTwo`.
// The result argument contains the pop result that is defined in `_PageTwo`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This is a PopScopeWithResult wrapper over _PageTwoBody
// This is a PopScopeWithResult wrapper over _PageTwoBody.

Copy link
Contributor

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.

Suggested change
onPopInvoked: (bool didPop, void result) {
onPopInvoked: (bool didPop, _) {

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onPopInvoked: (bool didPop, void result) {
onPopInvoked: (bool didPop, _) {

Copy link
Contributor

@navaronbracke navaronbracke Apr 19, 2024

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Deprecated, use [PopInvokedWithResultCallback] instead
/// Deprecated, use [PopInvokedWithResultCallback] instead.

Copy link
Contributor

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:

Suggested change
/// 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`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This sample demonstrates showing how to use PopScope to wrap widget that
/// This sample demonstrates how to use PopScope to wrap a widget that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Copy link
Contributor

@justinmc justinmc left a 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 😭

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be indented.

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be child.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@chunhtai
Copy link
Contributor Author

chunhtai commented Apr 19, 2024

Someone reminded me it is against style guide for breaking change. I found this in style guide

If you decide your change is valuable enough to deploy, adjust your PR so that it introduces the new functionality, API, behavior change, etc, in an opt-in fashion, thus avoiding the immediate breakage.

For example, rather than replacing a widget with another, introduce the new widget and discourage use of the old one. Rather than changing the order in which a certain argument is processed, provide a flag that selects which order the arguments will be processed in.

When changing the semantics of an API with a temporary opt-in, a three-phase change is needed (adding the new API and opt-in, then removing the old API, then removing the opt-in.)

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 Object?, and then reimplement the original onPopInvoked. but I am not sure if losing type safe is worth it.

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?

@chunhtai
Copy link
Contributor Author

chunhtai commented Apr 19, 2024

I guess I will just do the latter, it seems to make the most sense

@chunhtai chunhtai changed the title add a new popscopewithresult widget to replace popscope add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke Apr 22, 2024
@chunhtai chunhtai requested a review from navaronbracke April 22, 2024 19:28
Copy link
Contributor

@justinmc justinmc left a 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.

Copy link
Contributor

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"

Copy link
Contributor

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.

Copy link
Contributor

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.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 25, 2024
@auto-submit auto-submit bot merged commit 8031a3e into flutter:master Apr 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 26, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 26, 2024
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
@chunhtai chunhtai added the revert Autorevert PR (with "Reason for revert:" comment) label Apr 30, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 30, 2024

Time to revert pull request flutter/flutter/147016 has elapsed.
You need to open the revert manually and process as a regular pull request.

@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Apr 30, 2024
@chunhtai
Copy link
Contributor Author

https://github.com/ethanblake4/flutter_eval needs to be migrated in order to roll this change into internal code base

chunhtai added a commit to chunhtai/flutter that referenced this pull request Apr 30, 2024
chunhtai added a commit that referenced this pull request Apr 30, 2024
#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
chingjun pushed a commit to chingjun/flutter that referenced this pull request Apr 30, 2024
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
@justinmc justinmc mentioned this pull request May 1, 2024
9 tasks
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
@IanVS
Copy link

IanVS commented Sep 3, 2024

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 onPopInvoked? (https://docs.flutter.dev/release/breaking-changes/android-predictive-back#migrating-a-back-confirmation-dialog)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants