-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[go_router_builder] Add support for relative routes #7174
Conversation
- Adds `TypedRelativeGoRoute`
…for `concatenateUris`
…ly use dependency_overrides to take local go_router
…Route's extension
I temporarily added the dependency_overrides until the go_router PR gets merged. However, imho that should be there to avoid this type of PR split anyway |
@@ -390,6 +390,28 @@ class TypedGoRoute<T extends GoRouteData> extends TypedRoute<T> { | |||
final List<TypedRoute<RouteData>> routes; | |||
} | |||
|
|||
/// A superclass for each typed go route descendant | |||
@Target(<TargetKind>{TargetKind.library, TargetKind.classType}) | |||
class TypedRelativeGoRoute<T extends GoRouteData> extends TypedRoute<T> { |
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 can't see the difference between this and TypedGoRoute
it seems to me that if user uses go_router_builder they are not using url string to navigate so they don't really need relative routing?
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.
Well they won't be using './$path' directly, but they'll use route.goRelative()
, which uses that under the hood.
Not sure if I got your question right thou..
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 meant they could define a TypedGoRoute directly and do GoRouteData.go, why would they want to define a TypedRelativeRoute ?
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.
They can't define TypedGoRoute in multiple places. Take the example in the description, the relativeRoute was declared in a variable and passed in 2 routes. Had that been normal TypedGoRoute, it would've produced 2 extensions with the same name, of which locations are different, and results in build time error
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.
This seems to be two different feature right?
- is to be able to do
go('./relative')
- is to be able to reuse the same RouteData with same relative path in different sub route.
and 2 needs to build on top of 1.
If so I think we should separate the 2 into a new pr to make review simpler.
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.
oh looks like you already did #6825.
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.
okay... so do I need to change anything else?
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 would suggest removing the TypeRelativeRoute from #6825 and do all the TypeRelativeRoute thing in a separate pr
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.
TypedRelativeRoute needs to be landed in order for this PR to work. The reason this PR is working right now is because of the dependency_overrides
, which I meant to remove after the #6825 is merged. Can you suggest how do I remove the TypedRelativeRoute? Do I create a PR with only TypedRelativeRoute
declaration, wait for it to get merged and then continue with this PR?
Imo it's feels weird to me that an annotation of a builder package belongs to the main package and not in the builder package, but maybe there is a technical reason for that that I don't know
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 am going to close this pr since inactive, feel free to reopen when you have time |
Add supports for relative routes by allowing going to a path relatively, like go('./$path') This PR doesn't fully resolve any issue, but it's mandatory to further add examples & tests for `TypedRelativeGoRoute` (see [#7174](#6823)), which will resolves [#108177](flutter/flutter#108177)
Add supports for relative routes by allowing going to a path relatively, like go('./$path')
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.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.