[go_router] Add support for relative routes#6825
[go_router] Add support for relative routes#6825auto-submit[bot] merged 20 commits intoflutter:mainfrom
Conversation
|
@chunhtai I separated the PR as suggested. Please let me know the next steps |
|
Why don't you add it to the existing api. is pretty common in router modules in other frameworks as well as in bash |
Oh yea that's cool. I didn't know of that pattern |
chunhtai
left a comment
There was a problem hiding this comment.
I also agree we should probably use go(./something) for relative path instead of adding new API. Seems more straigtforward
There was a problem hiding this comment.
Why not just modify the path and use currentUri.replace(path: newPath)
This way you don't need to worry about other thing such as host/scheme/fragment/queryparameters
There was a problem hiding this comment.
Gotcha. I move this in path_utils as concatenateUris
9aa61bd to
975128b
Compare
| /// Concatenates two Uri. It will [concatenatePaths] the parent's and the child's paths , then merges their query parameters. | ||
| /// | ||
| /// e.g: pathA = /a?fid=f1, pathB = c/d?pid=p2, concatenatePaths(pathA, pathB) = /a/c/d?fid=1&pid=2. | ||
| Uri concatenateUris(Uri parentUri, Uri childUri) { |
There was a problem hiding this comment.
the path looks good, but I am a bit hesitate on also merge query parameter. It has different logic from regular go. Regular go will not attempt to merge with current query parameters. I think we should probably follow the same logic to avoid confusion.
There was a problem hiding this comment.
Hmm this is quite interesting thing thou. Take this example.
We're in /family/f2?sort=desc and we're going to the inner person/p1 route, and we'll pop it to go back to the family route. How are devs handling this case?
In go_router_builder, devs can't use the easy PersonRoute(pid: 'p1').go but rather have to get its route.location, convert to Uri, and then manually add the sort param. Being able to use Route().go in builder is kinda a big selling point of the package imo
There was a problem hiding this comment.
you can access GoRouterState.of(context).uri.queryParemeters.
Also won't in this case PersonRoute also declare sort parameter?
There was a problem hiding this comment.
make sense. I've been doing things wrong in my app then
| } | ||
|
|
||
| /// A superclass for each typed go route descendant | ||
| @Target(<TargetKind>{TargetKind.library, TargetKind.classType}) |
There was a problem hiding this comment.
Can you also create a go_router_builder pr that shows how this will be used?
0626fb1 to
b15b23b
Compare
- Adds `TypedRelativeGoRoute`
…for `concatenateUris`
b15b23b to
43eb497
Compare
chunhtai
left a comment
There was a problem hiding this comment.
just pointing out one issue, otherwise, LGTM
| Uri concatenateUris(Uri parentUri, Uri childUri) { | ||
| Uri newUri = parentUri.replace( | ||
| path: concatenatePaths(parentUri.path, childUri.path), | ||
| queryParameters: childUri.queryParameters, |
There was a problem hiding this comment.
we should probably have some test for fragment as well
|
@thangmoxielabs This branch has conflicts that must be resolved |
|
@ThangVuNguyenViet This branch has conflicts that must be resolved |
You can fork and redo a pr |
|
@cedvdb hey sorry for the late reply. I didn't see any notification |
|
@chunhtai @hannah-hyj |
|
This somehow slip through the crack. @thangmoxielabs can you fix the conflict again? sorry about the delay |
|
@chunhtai resolved it |
|
Hi @ThangVuNguyenViet you also need to bump the package.yaml version |
|
Hey @chunhtai it's bumped |
|
Hi @chunhtai |
flutter/packages@72356fd...26e123a 2024-11-13 dasyad00@gmail.com [camera_windows] Set device media type for video preview explicitly (flutter/packages#7447) 2024-11-13 39979207+ThangVuNguyenViet@users.noreply.github.com [go_router] Add support for relative routes (flutter/packages#6825) 2024-11-13 pq@users.noreply.github.com [vector_graphics_compiler] fix a renamed method parameter lint (flutter/packages#8070) 2024-11-12 feinstein@users.noreply.github.com [in_app_purchase] Add expiration date to Transaction (flutter/packages#8030) 2024-11-12 stuartmorgan@google.com [various] Clean up contributing guides (flutter/packages#8032) 2024-11-12 ditman@gmail.com [ci] Remove web renderer option from tools. (flutter/packages#8055) 2024-11-12 stuartmorgan@google.com [url_launcher] Update Pigeon version for Linux (flutter/packages#8065) 2024-11-12 tobias@leafnode.se [go_router] Add support for preloading branches of StatefulShellRoute (revised solution) (flutter/packages#6467) 2024-11-12 stuartmorgan@google.com [pigeon] Make Linux type declarations public (flutter/packages#8040) 2024-11-11 engine-flutter-autoroll@skia.org Roll Flutter from 73546b3 to c8510f2 (30 revisions) (flutter/packages#8042) 2024-11-11 magder@google.com Use dependabot multi-directory configuration for Android package updates (flutter/packages#8048) 2024-11-11 stuartmorgan@google.com [tools] Run `pub get` before `format` (flutter/packages#8052) 2024-11-11 stuartmorgan@google.com [file_selector] Fix Linux cancel regression (flutter/packages#8051) 2024-11-09 stuartmorgan@google.com [shared_preferences] Fix confusing language in README (flutter/packages#8049) 2024-11-08 magder@google.com Use dependabot multi-directory configuration for Android example gradle updates (flutter/packages#8036) 2024-11-08 43054281+camsim99@users.noreply.github.com [animations] Remove `.flutter-plugins` reference from example app (flutter/packages#8002) 2024-11-08 magder@google.com Group dependabot github-action update PRs, delete dead docker updates (flutter/packages#8044) 2024-11-08 37028599+EArminjon@users.noreply.github.com [vector_graphics_compiler] fix-null-exception (flutter/packages#8006) 2024-11-08 stuartmorgan@google.com [tools] Format Dart per-package (flutter/packages#8043) 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 flutter-ecosystem@google.com 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
|
@chunhtai @ThangVuNguyenViet strange behaviour occurs when using context.push instead of context.go Example: When using context.go('./select-method');
context.go('./withdraw');it's okay. When using context.push('./select-method');
context.push('./withdraw');we got |
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), which will resolves #108177Pre-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, or this PR is exempt from CHANGELOG changes.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.