[go_router] Refactored RouteMatchList and imperative APIs#5497
[go_router] Refactored RouteMatchList and imperative APIs#5497auto-submit[bot] merged 9 commits intoflutter:mainfrom
Conversation
|
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 or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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. |
77e95ca to
109bdfc
Compare
There was a problem hiding this comment.
most of the recursive build pages logic is moved to _CustomNavigatorState
There was a problem hiding this comment.
previously we need to scan the list and use parent navigator key to jump around the list. Therefore i created this iterator to abstract away the logic.
After the refactor we just need to look at the last node in the RouteMatchList and walk up the tree branch.
There was a problem hiding this comment.
This is the most complex part in this pr, previously match just produce a RouteMatch for the input route.
After this change, this match will recursively match the subroute in route and return the entire route matches if it finds the full match.
There was a problem hiding this comment.
Remove is usually caused by pop
by usually do you mean there are other cases?
this function looks like it assumes all removal is pop. it not only removes the target, but also remove all matches after the target.
There was a problem hiding this comment.
I found the name leafMatch a bit confusing cause a tree can have many leaves. Maybe lastLeaf is more clear?
There was a problem hiding this comment.
gramma is correct here since I am describing a fact, but the return may not be a good word here. will update
73d0cd2 to
0e058a5
Compare
| configuration: configuration, | ||
| errorBuilder: errorBuilder, | ||
| errorPageBuilder: errorPageBuilder, | ||
| )); |
| required this.navigatorRestorationId, | ||
| required this.onPopPageWithRouteMatch, | ||
| required this.matchList, | ||
| required this.matches, |
There was a problem hiding this comment.
why pass both matchList and matches? Can you add some comments?
| registry: _registry, | ||
| child: HeroControllerScope( | ||
| controller: _controller!, | ||
| child: Builder( |
There was a problem hiding this comment.
Builder() here seems like unnecessary. context is not used.
| // Grabs the route matches for the scope navigator key and put it into the | ||
| // matches for `null`. | ||
| if (result.containsKey(scopedNavigatorKey)) { | ||
| final List<RouteMatchBase> matchForScopedNavigator = |
There was a problem hiding this comment.
nit matchesForScopedNavigator
| ); | ||
| } else { | ||
| assert(false, 'Unexpected route type: $route'); | ||
| return const <GlobalKey<NavigatorState>?, List<RouteMatchBase>>{}; |
There was a problem hiding this comment.
| return const <GlobalKey<NavigatorState>?, List<RouteMatchBase>>{}; | |
| return const _empty; |
| required Uri uri, | ||
| }) { | ||
| final GlobalKey<NavigatorState>? parentKey = | ||
| route.parentNavigatorKey == null || |
packages/go_router/CHANGELOG.md
Outdated
| @@ -1,3 +1,10 @@ | |||
| ## 13.0.0 | |||
|
|
|||
| - Refactored `RouteMatchList` and imperative APIs. | |||
Migration guide for flutter/packages#5497
flutter/packages@4c3bc49...23d2d9c 2023-12-22 49699333+dependabot[bot]@users.noreply.github.com Bump lewagon/wait-on-check-action from 1.3.1 to 1.3.3 (flutter/packages#5737) 2023-12-21 [email protected] Disable `presubmit: false` targets for recipes CQ (flutter/packages#5735) 2023-12-21 [email protected] [go_router] Refactored RouteMatchList and imperative APIs (flutter/packages#5497) 2023-12-21 [email protected] Add env_variables in ci.yaml (flutter/packages#5730) 2023-12-21 [email protected] Roll Flutter (stable) from 2e9cb0a to 78666c8 (1 revision) (flutter/packages#5734) 2023-12-21 [email protected] Roll Flutter from da0cd69 to 11def8e (16 revisions) (flutter/packages#5732) 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-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@4c3bc49...23d2d9c 2023-12-22 49699333+dependabot[bot]@users.noreply.github.com Bump lewagon/wait-on-check-action from 1.3.1 to 1.3.3 (flutter/packages#5737) 2023-12-21 [email protected] Disable `presubmit: false` targets for recipes CQ (flutter/packages#5735) 2023-12-21 [email protected] [go_router] Refactored RouteMatchList and imperative APIs (flutter/packages#5497) 2023-12-21 [email protected] Add env_variables in ci.yaml (flutter/packages#5730) 2023-12-21 [email protected] Roll Flutter (stable) from 2e9cb0a to 78666c8 (1 revision) (flutter/packages#5734) 2023-12-21 [email protected] Roll Flutter from da0cd69 to 11def8e (16 revisions) (flutter/packages#5732) 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-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This pr refactor RouteMatchList to be a tree structure.
Added a common base class RouteMatchBase. It is extended by both RouteMatch and ShellRouteMatch.
The RouteMatch is for GoRoute, and is always a leaf node
The ShellRouteMatch is for ShellRouteBase, and is always and intermediate node with a list of child RouteMatchBase[s].
This pr also redo how push is processed. Will add a doc explain this shortly.
This is a breaking change, will write a migration guide soon.
fixes flutter/flutter#134524
fixes flutter/flutter#130406
fixes flutter/flutter#126365
fixes flutter/flutter#125752
fixes flutter/flutter#120791
fixes flutter/flutter#120665
fixes flutter/flutter#113001
fixes flutter/flutter#110512
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.