-
Notifications
You must be signed in to change notification settings - Fork 0
[go_router_builder]: Add support for relative routes #1
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 #1
Conversation
d59d222
to
f778d2e
Compare
c280a01
to
a501098
Compare
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.
Can you also add a readme section for the goRelative route?
@gemini-code-assist Can you add a section to talk about how to use goRelative in the readme.md follow the same format as the existing content in the readme ?
TypedRelativeGoRoute<DetailsRoute>( | ||
path: 'details/:detailId', | ||
routes: <TypedRoute<RouteData>>[ | ||
TypedRelativeGoRoute<SettingsRoute>(path: 'settings/:settingId'), |
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 will happen if this is another TypedGoRoute? or should we assert or force the type of the routes
to TypedRelativeGoRoute or TypedShellRoute?
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 added a build-time check in RouteBaseConfig._fromAnnotation
. Do you agree with that approach?
Do you think it's necessary to add an assert in TypedRelativeGoRoute
as well?
// if there are any queryParam objects, add in the `queryParam` bits | ||
String get _locationArgs { | ||
final Map<String, String> pathParameters = Map<String, String>.fromEntries( | ||
_pathParams.map((String pathParameter) { |
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.
can you factor this out so we don't duplicate the logic between this and goRoute version?
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.
Done! 👍
return "'$location'"; | ||
} | ||
|
||
ParameterElement? get _extraParam => _ctor.parameters |
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.
same for these getter, or consider using mixin
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.
Done! 👍
oh looks like this is a pr in fork. Once you are ready, can you open a pr against main repo? we usually review both go_router and go_router_builder pr together, and only start merging once both are approved |
f778d2e
to
e8c8f2b
Compare
a501098
to
ba35aa3
Compare
b139041
to
11e0b72
Compare
Reopened in flutter/packages (flutter#9749) and added a readme section. |
Adds support for
TypedRelativeGoRoute
.Builds on flutter#9732
Continuation of flutter#8476 by @ThangVuNguyenViet
Compared to flutter#8476, the approach taken in this PR avoids breaking changes and creates a separate RouteData subclass instead of extending GoRouteData. The approach increases flexibility and avoids extending behavior that might not make sense for a relative route.
Fully resolves flutter/flutter#108177.
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assist
bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3