Skip to content

app bar leading back button should not change if the route is popped - #71944

Merged
fluttergithubbot merged 3 commits into
flutter:masterfrom
chunhtai:issues/67277
Jan 6, 2021
Merged

fluttergithubbot merged 3 commits into
flutter:masterfrom
chunhtai:issues/67277

Conversation

@chunhtai

@chunhtai chunhtai commented Dec 8, 2020 •

Copy link
Copy Markdown
Contributor

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@flutter-dashboard flutter-dashboard Bot added p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Dec 8, 2020
@google-cla google-cla Bot added the cla: yes label Dec 8, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we assert(previouslyImplyLeadingPopupButton != null) here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this flag ever need to be reset to null?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe call this hadBackButtonWhenRouteWasActive and include a comment that explains what the variable means when it's null, as well as true/false.

@chunhtai

Copy link
Copy Markdown
Contributor Author

thanks for reviewing, I addressed all comments.

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The back button appears for a few moments while I replace a route with Navigator 2.0.

3 participants