-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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] replace
should reuse the same key as the popped page when possible
#115902
Labels
found in release: 3.3
Found to occur in 3.3
found in release: 3.6
Found to occur in 3.6
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
p: go_router
The go_router package
P2
Important issues not at the top of the work list
package
flutter/packages repository. See also p: labels.
r: fixed
Issue is closed as already fixed in a newer version
Comments
Issue is reproducible using the code sample and steps outlined above. flutter doctor -v
|
11 tasks
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
found in release: 3.3
Found to occur in 3.3
found in release: 3.6
Found to occur in 3.6
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
p: go_router
The go_router package
P2
Important issues not at the top of the work list
package
flutter/packages repository. See also p: labels.
r: fixed
Issue is closed as already fixed in a newer version
This comes back to this issue #114234 and this PR flutter/packages#2747.
Before the keys of pages being pushed then replaced were:
and I thought the pages keys should have been (what was done in flutter/packages#2747)
because the example given in #114234 was with a
Dialog
and it wasn't rebuilding when the same key was reused.But after more investigation, it looks like it should have rebuilt when the same key was reused and this might be a bug with the dialog route itself because it doesn't rebuild when it should. See #115639
So now, because the keys are different after a
replace
, the state is lost when it is being used.So I think the keys of the page should instead be (the key of the popped page should be reused when possible to preserve the state of the widgets).
Steps to Reproduce
flutter run
on the code sample see "Code sample" section belowreplace
.now
(set in theinitState
) displays a different time on each page.Expected results:
The state should be preserved when possible
Actual results:
The state is not preserved.
Code sample
Or you can checkout
https://github.com/ValentinVignal/flutter_app_stable/tree/go-router/replace-use-same-key
Logs
Video
Screen.Recording.2022-11-23.at.3.14.41.PM.mov
The text was updated successfully, but these errors were encountered: