Fixes navigator may not report correct canhandlepop when propagate in…#186705
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors NavigatorState to centralize pop-handling logic within a new _getNavigatorCanHandlePop method and adds a test case for nested navigators using PopScope. The review feedback suggests simplifying the logic in _getNavigatorCanHandlePop to improve efficiency and adding documentation to the private method to align with the repository's style guide.
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: <Widget>[Text('Home/PopScope Page')], | ||
| ), | ||
| testWidgets('pop scope can have Object? generic type while route has stricter generic type', ( |
There was a problem hiding this comment.
these are format change
…ner navigation notification
justinmc
left a comment
There was a problem hiding this comment.
Thanks for fixing! Indeed that's an oversight of PopScope in between Navigators.
| if (notification.canHandlePop || !canPop()) { | ||
| if (notification.canHandlePop || !_getNavigatorCanHandlePop()) { |
|
autosubmit label was removed for flutter/flutter/186705, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
flutter#186705) …ner navigation notification <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> When propagate the notifcation from the inner nested navigator, it didn't take the PopScope in between the two navigator into account. if the widget tree looks like this ``` Navigator1 PopScope(canpop: false) Navigator2 ``` when the navigator 2 report canHandlePop = false, the Navigator1 receives it but it just check against its NavigatorState.canPop, which doesn't take the PopScope in between into account. This pr changes the logic that it now also check the modalroute's popdisposition fixes flutter#181945 ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [ ] 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]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#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/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…ner navigation notification
When propagate the notifcation from the inner nested navigator, it didn't take the PopScope in between the two navigator into account.
if the widget tree looks like this
when the navigator 2 report canHandlePop = false, the Navigator1 receives it but it just check against its NavigatorState.canPop, which doesn't take the PopScope in between into account.
This pr changes the logic that it now also check the modalroute's popdisposition
fixes #181945
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.