Skip to content

Tiny cleanup for Navigator code (without introducing dependency) - #125628

Merged
auto-submit[bot] merged 15 commits into
flutter:masterfrom
fzyzcjy:feat/cleanup-navigator
May 8, 2023
Merged

auto-submit[bot] merged 15 commits into
flutter:masterfrom
fzyzcjy:feat/cleanup-navigator

Conversation

@fzyzcjy

@fzyzcjy fzyzcjy commented Apr 27, 2023 •

Copy link
Copy Markdown
Contributor

Close #125724

The navigator.dart has ~10 repeats of things like:

    final _RouteEntry? currentRouteEntry = _navigator!._history.cast<_RouteEntry?>().lastWhere(
      (_RouteEntry? e) => e != null && _RouteEntry.isPresentPredicate(e),
      orElse: () => null,
    );

while it can be greatly simplified as:

    final _RouteEntry? currentRouteEntry = _navigator!._history.lastWhereOrNull(_RouteEntry.isPresentPredicate);

Thus, it seems that we can beautify the code a little bit.

Same as #125099, but without external dependency

For more detailed explanation why it does not introduce external dependency: #125099 (comment)

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.
  • 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 f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. labels Apr 27, 2023
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Piinks
Piinks requested a review from chunhtai April 27, 2023 18:23
@Piinks

Piinks commented Apr 27, 2023

Copy link
Copy Markdown
Contributor

Hey @fzyzcjy is there an issue this is resolving? Can you update the description of the PR with an explanation of what this change is doing?

@fzyzcjy

fzyzcjy commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

@Piinks Hi, it is solving the same issue as #125099 mentions. The former issue was closed because hixie thought that the external dependency should not be introduced, hence this PR.

Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
@Piinks

Piinks commented Apr 28, 2023

Copy link
Copy Markdown
Contributor

it is solving the same issue as #125099 mentions.

Can you update the PR description to link to the issue and explain the fix? Having to backtrack through other PRs and issues is difficult to follow. :)

Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
@Hixie

Hixie commented Apr 28, 2023

Copy link
Copy Markdown
Contributor

test-exempt: refactor (in case the test is removed)

@fzyzcjy

fzyzcjy commented Apr 28, 2023

Copy link
Copy Markdown
Contributor Author

@Piinks Done

@fzyzcjy

fzyzcjy commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

@chunhtai done

@chunhtai chunhtai 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

Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated
Comment thread packages/flutter/lib/src/widgets/navigator.dart Outdated

@Piinks Piinks 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 thank you!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2023
@auto-submit
auto-submit Bot merged commit 431dfc8 into flutter:master May 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 9, 2023
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 9, 2023
flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 [email protected] tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 [email protected] Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 [email protected] Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 [email protected]  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 [email protected] Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 [email protected] [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 [email protected] Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 [email protected] Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 [email protected] Roll Packages from a0f8fd8 to 4800d65 (2 revisions) (flutter/flutter#126269)
2023-05-08 [email protected] Test AGP 8.0 using java 17 (flutter/flutter#125323)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 [email protected] tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 [email protected] Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 [email protected] Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 [email protected]  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 [email protected] Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 [email protected] [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 [email protected] Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 [email protected] Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 [email protected] Roll Packages from a0f8fd8 to 4800d65 (2 revisions) (flutter/flutter#126269)
2023-05-08 [email protected] Test AGP 8.0 using java 17 (flutter/flutter#125323)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

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 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 [email protected] tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 [email protected] Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 [email protected] Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 [email protected]  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 [email protected] Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 [email protected] [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 [email protected] Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 [email protected] Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 [email protected] Roll Packages from a0f8fd8 to 4800d65 (2 revisions) (flutter/flutter#126269)
2023-05-08 [email protected] Test AGP 8.0 using java 17 (flutter/flutter#125323)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 [email protected] tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 [email protected] Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 [email protected] Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 [email protected] Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 [email protected]  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 [email protected] Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 [email protected] [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 [email protected] Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 [email protected] Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 [email protected] Roll Packages from 7bce9f6 to bae1300 (2 revisions) (flutter/flutter#126269)
2023-05-08 [email protected] Test AGP 8.0 using java 17 (flutter/flutter#125323)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App 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.

Cleanup for Navigator code

4 participants