Repository navigation
app bar leading back button should not change if the route is popped - #71944
Merged
Merged
Conversation
HansMuller
reviewed
Dec 14, 2020
Contributor
There was a problem hiding this comment.
Can we assert(previouslyImplyLeadingPopupButton != null) here?
Contributor
There was a problem hiding this comment.
I thought the objective was to leave the back button alone if a route became inactive (it was popped) and it had a back button before it became inactive? Maybe this should be?
previouslyImplyLeadingPopButton ??= false;
Contributor
There was a problem hiding this comment.
Does this flag ever need to be reset to null?
HansMuller
reviewed
Dec 14, 2020
Contributor
There was a problem hiding this comment.
Maybe call this hadBackButtonWhenRouteWasActive and include a comment that explains what the variable means when it's null, as well as true/false.
chunhtai
force-pushed
the
issues/67277
branch
from
December 21, 2020 20:21
0e8cc82 to
42f369d
Compare
Contributor
Author
|
thanks for reviewing, I addressed all comments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
There are two issues, the canPop was based on whether the route isFirst or not
bool canPop => !isFirst || willHandlePopInternally
this is inaccurate because a route is no longer the first route when it is popped. The canpop will return true in this case.
but once we fix that we will encounter the second issue: the appbar back button is show when the route.canPop return true.
That means if there are two routes in the history stack, the topmost route canpop return true, and the back button is displayed. As soon as the back button is pressed, the canpop become false. The back button will disappear. Thus I implemented a mechanism to memorize previous decision to show the back button in Appbar if the route is not active.
Related Issues
fixes #67277
Tests
I added the following tests:
see files
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.