[go_router] Refactor RouterDelegate into functional pieces#1653
[go_router] Refactor RouterDelegate into functional pieces#1653johnpryan merged 1 commit intoflutter:mainfrom
Conversation
7331b08 to
ea2eb4f
Compare
3081965 to
be0f48a
Compare
There was a problem hiding this comment.
nit: I think you can use this type directly as long as we set the Dart SDK constraint to >=2.17.0 <3.0.0
| // ignore: unnecessary_non_null_assertion | |
| static WidgetsBinding get _binding => WidgetsBinding.instance!; | |
| static WidgetsBinding get _binding => WidgetsBinding.instance; |
There was a problem hiding this comment.
I think the cirrus still use 2.16.xx, I can skip it but I think it is probably better to keep this so that it can still be analyzed
There was a problem hiding this comment.
Why does selectMultiEntryHistory() need to be called? The docs say it's the default.
There was a problem hiding this comment.
If there is another MateriaApp wraps on top, it may have switched to single entry history.
There was a problem hiding this comment.
nit: add a comment:
| final bool replace = type == RouteInformationReportingType.neglect || | |
| // Avoid adding a new history entry if the route is the same as before. | |
| final bool replace = type == RouteInformationReportingType.neglect || |
There was a problem hiding this comment.
Was this removed because it was unused? I see that namedLocation moved from GoRouterDelegate into GoRouteInformationParser, but I don't see what happened to this method.
There was a problem hiding this comment.
yes i moved the functionality to goRouteInformationParser, GoRouteMatch is not exposed to the package level
There was a problem hiding this comment.
It doesn't look like there are any tests for this method - I'll probably add some when I start working on flutter/flutter#99126
There was a problem hiding this comment.
This method should be covered by a lot of test indirectly, any test that build the page from uri should do
There was a problem hiding this comment.
Right, but I think it's important enough to have it's own set of tests eventually.
There was a problem hiding this comment.
I can add it in this patch
There was a problem hiding this comment.
Not sure if it's helpful, but there's some test cases in this file that might be useful to consider: https://github.com/johnpryan/tree_router/blob/main/test/tree_test.dart
be0f48a to
8470008
Compare
|
It looks like there's still some analyzer warnings: |
2a907cf to
2a293bb
Compare
|
Please make sure flutter/flutter#105150 (comment) is addressed before this is re-landed in any form (or any other changes are landed to |
|
It sounds like the better option is to combine go_router_builder and go_router into a single package? |
That would fix the problem in this particular instance, but leave the fundamental problem that makes changing
I don't know the details of these packages, but I'm unclear as to why the solution isn't just to have a normal, pub-based dependency on |
If we did that, wouldn't we run into a similar problem? When a change to |
|
Unless the dependency were an |
|
In this case, there wasn't enough test coverage to catch the bug fixed in #2177, but we could certainly make |
|
|
||
| environment: | ||
| sdk: ">=2.12.0 <3.0.0" | ||
| flutter: ">=2.0.0" |
There was a problem hiding this comment.
shouldn't the package depend on flutter 3.0.0 ? i am getting WidgetsBinding.instance warnings
because of static WidgetsBinding get _binding => WidgetsBinding.instance!;
* Revert "Revert "[go_router] Refactor RouterDelegate into functional pieces (#1653)" (#2183)" This reverts commit d39ffb1. * [go_router] Continue searching for top-level routes if the recursive search doesn't find any * Remove Route.push from demo app * update CHANGELOG.md * Avoid pushing the same page in example bump go_router_builder to 1.0.5 * Change published version to 4.0.0 * Specify dart SDK version >=2.17.0 to avoid analyzer errors Analyzing go_router... error - lib/src/go_route_information_provider.dart:24:41 - A value of type 'WidgetsBinding?' can't be returned from the function '_binding' because it has a return type of 'WidgetsBinding'. - return_of_invalid_type error - lib/src/go_router.dart:51:33 - The property 'platformDispatcher' can't be unconditionally accessed because the receiver can be 'null'. Try making the access conditional (using '?.') or adding a null check to the target ('!'). - unchecked_use_of_nullable_value 2 issues found. * Specify flutter >=3.0.0 in go_router * Apply suggestions from code review Co-authored-by: Loïc Sharma <[email protected]> * Apply suggestions from code review * Update packages/go_router/lib/src/go_route_information_parser.dart Co-authored-by: Loïc Sharma <[email protected]> * Update packages/go_router/lib/src/go_route_information_parser.dart Co-authored-by: Loïc Sharma <[email protected]> * Update packages/go_router/lib/src/go_route_information_parser.dart Co-authored-by: Loïc Sharma <[email protected]> * Update packages/go_router/lib/src/go_route_information_parser.dart Co-authored-by: Loïc Sharma <[email protected]> * Add '/' route to test * add go_route_information_provider_test.dart * Add test for redirect detection in GoRouteInformationParser * format Co-authored-by: Loïc Sharma <[email protected]>
This change will break the following:
breaking change doc flutter.dev/go/go-router-v4-breaking-changes
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.