-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[go_router_builder] Add support for relative routes #8476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Adds `TypedRelativeGoRoute`
…for `concatenateUris`
…ly use dependency_overrides to take local go_router
…Route's extension
@chunhtai same issue I asked in the old PR. The test will fail without the temp dependency_overrides. Should I make a PR that contains only the |
final GoRouter _router = GoRouter( | ||
routes: $appRoutes, | ||
); | ||
const TypedRelativeGoRoute<DetailsRoute> detailRoute = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is different between using this vs a regular TypedGoRoute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example I gave isn't clearly explaining the purpose. Let me update this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can't see the difference. Is this a way to reuse the typedGoRoute in multiple places in the routing tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Without this you'd have to define routes like
SettingsFromHomeRoute
SettingsFromDashboardRoute
And those routes all build (or build page) the same screen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this makes sense. I will take another look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just updated the example
final GoRouter _router = GoRouter( | ||
routes: $appRoutes, | ||
); | ||
const TypedRelativeGoRoute<DetailsRoute> detailRoute = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment #8476 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @ThangVuNguyenViet looks like there are some test failures, can you fix it so that we can land this pr? |
sure I'll do that |
@ThangVuNguyenViet I was doing a bit of testing of relative routes as we may be looking to use them in our project, and I had a question RE: the generation of
However, ════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for GoRouteInformationProvider:
'package:go_router/src/match.dart': Failed assertion: line 235 pos 12: 'uri.path.startsWith(newMatchedLocation)': is not true.
When the exception was thrown, this was the stack:
#2 RouteMatchBase._matchByNavigatorKeyForGoRoute (package:go_router/src/match.dart:235:12)
match.dart:235
#3 RouteMatchBase._matchByNavigatorKey (package:go_router/src/match.dart:110:16) Is there a use-case for using the |
Hi @ThangVuNguyenViet , do you have a chance to look into the error? |
I'll check that out. Sorry for late reply, not seeing the email |
@btrautmann hey could you provide reproducible code? I can't reproduce it |
@ThangVuNguyenViet @chunhtai @hannah-hyj This looks awesome and offers lots of routing flexibility for apps at large scale. Looks like tests are passing. Could this be prioritized for merging? Thanks! |
Idk, seems like there is an error, which I can't reproduce |
@thangmoxielabs I think @btrautmann's comment on
Doesn't work: It's more of a dev experience concern, and it doesn't seem merge blocking. One might find that having the |
Oh yea I just reread his comment. Thought he was saying the .relativeLocation doesn't work |
And I do agree the relativeRoute.location is much much different from the normal route.location. Normal route is safe to call, no exception is expected. Relative routes are expected to throw exceptions if you don't know which route you're currently at. A trade off for the convenience |
We're hoping to use Relative Routes in an upcoming app version release (early July?) at our company. Is there any way we could accelerate merging this in? Happy to assist and contribute if that would help things move along-what are the blockers right now? |
I thinks it's more of a dev ex issue? |
Oh sorry I didn't mean that there was a blocker, I more just meant can we accelerate merging this? It looks like the only thing stopping us right now is you need to resolve the merge conflicts. Once the conflicts are merged, we're just waiting on @chunhtai to merge right? |
This PR is a 2nd part of #6825 to fully resolves flutter/flutter#108177, which allow users to use
TypedRelativeGoRoute
to construct the route relatively.This is a continuation of #7174
Example:
Basically the added TypedRelativeGoRoute allows us to construct the route tree above. If we replace it with the existing
TypedGoRoute
it will declare multiple extensions of a same thing and produce build time errorPre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.