-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[go_router] Make replace
use pop
and push
to generate a new pageKey
#2747
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] Make replace
use pop
and push
to generate a new pageKey
#2747
Conversation
The test
I don't think that is related to my changes? Do you want me to try to fix it in this PR or should I do another PR instead? |
no, it should be fixed by #2751 (comment) Can you rebase off the latest main? |
3574eae
to
9b20b5c
Compare
My current plan is to make the |
About flutter/flutter#99112 I'm not in favor of using pageless pages from However, our app is currently facing this bug, so I would say we could still push the fix. If we don't, the bug will still remain, which is an issue in my opinion. |
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, you are right, it shouldn't stop this pr from merging. I left some comments
@@ -71,17 +71,21 @@ class RouteMatchList { | |||
} | |||
|
|||
/// Removes the last match. | |||
void pop() { | |||
void pop({bool asserts = true}) { |
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.
seems weird as an API, I think we can move the _debugAssertNotEmpty check to RouterDelegate.pop instead
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.
and it should probably be wrapped in an assert
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.
seems weird as an API,
Yes, I do agree. But I saw somewhere that someone was thinking of making some router's field private (there was an issue where this was discussed). So I didn't know whether or not pop
would be not-accessible publicly at some point. In this case, it would have been fine.
But if not, yes, that's not a good idea to add this parameter.
I changed it in a50d124
…ith-push-count # Conflicts: # packages/go_router/CHANGELOG.md # packages/go_router/pubspec.yaml
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, %nits
/// Pop the top page off the GoRouter's page stack. | ||
void pop() { | ||
_matchList.pop(); | ||
_debugAssertMatchListNotEmpty(); |
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.
you can also wrap this in an assert so that release mode will not even waste time calling into an empty function
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.
Is 8e8d187 what you mean?
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
packages/go_router/pubspec.yaml
Outdated
@@ -1,7 +1,7 @@ | |||
name: go_router | |||
description: A declarative router for Flutter based on Navigation 2 supporting | |||
deep linking, data-driven routes and more | |||
version: 5.1.2 | |||
version: 5.1.4 |
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.
5.1.3?
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.
With the newly merged PRs, I'll make it 5.1.6
…ith-push-count # Conflicts: # packages/go_router/CHANGELOG.md # packages/go_router/pubspec.yaml
@johnpryan is there anything you want me to do on this PR ? |
auto label is removed for flutter/packages, pr: 2747, due to - The status or check suite web_benchmarks_test CHROMIUM_BUILD:950363 has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
Not sure why the ci stuck @ValentinVignal can you rebase off the latest main branch and try again? |
auto label is removed for flutter/packages, pr: 2747, due to - The status or check suite macos-platform_tests CHANNEL:master has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
…ith-push-count # Conflicts: # packages/go_router/CHANGELOG.md
@chunhtai It looks like it is fine now |
…geKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]>
[go_router] Make `replace` use `pop` and `push` to generate a new `pageKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]> Fix broken links in documentation update changelog
[go_router] Make `replace` use `pop` and `push` to generate a new `pageKey` (#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]> Fix broken links in documentation update changelog
…geKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]>
[go_router] Make `replace` use `pop` and `push` to generate a new `pageKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]> Fix broken links in documentation update changelog
…geKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]>
[go_router] Make `replace` use `pop` and `push` to generate a new `pageKey` (flutter#2747) * 🐛 Use pop and push in replace to generate a new pageKey * ✅ Test that replace creates a new page key * ⬆️ Increase the version number * ♻️ Move the asserts to the router deleguate * Wrap _debugAssertMatchListNotEmpty in an assert * Update packages/go_router/lib/src/delegate.dart Co-authored-by: John Ryan <[email protected]> Fix broken links in documentation update changelog
Refactores
replace
to usepop
andpush
to a unique page key is used every timereplace
is used.Fixes flutter/flutter#114234
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-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.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.