Skip to content

Fix canpop logic to be more robust - #73993

Merged
fluttergithubbot merged 2 commits into
flutter:masterfrom
chunhtai:issues/73956
Jan 15, 2021
Merged

fluttergithubbot merged 2 commits into
flutter:masterfrom
chunhtai:issues/73956

Conversation

@chunhtai

Copy link
Copy Markdown
Contributor

As title

Fixes #73956

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 listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard Bot added p: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Jan 14, 2021
@google-cla google-cla Bot added the cla: yes label Jan 14, 2021
@chunhtai
chunhtai requested a review from goderbauer January 14, 2021 23:47

@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


/// Whether this route can be popped.
///
/// A route can be popped if there is at least one active route underneath

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.

A route can be popped if there is at least one active route below it, or if [willHandlePopInternally] returns true.

/// rebuild, and any widgets that used [ModalRoute.of] will be
/// notified.
bool get canPop => isActive && (!isFirst || willHandlePopInternally);
bool get canPop => hasActiveRouteBelow || willHandlePopInternally;

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.

This is much easier to understand than the old version :-)

}
return false;
}
_navigator!._history.cast<_RouteEntry?>().firstWhere(

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.

This is OK, although a for loop might have been simpler.

@goderbauer goderbauer left a comment

Copy link
Copy Markdown
Member

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: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoNavigationBar crashes when pressing back button

4 participants