Skip to content
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] fix Popping state and re-rendering scaffold at the same time doesn't update the URL on web [new] #8352

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahyangnb
Copy link

@ahyangnb ahyangnb commented Dec 28, 2024

the old pr #6953

Change the 3 files of lib and add a example, because issue flutter/flutter#150312

The reason for the issue is when call counterStream.increment(); will notify notifyListeners() of StreamListener, and finally affect _handleRouteInformationProviderNotification of _RouterState in packages/flutter/lib/src/widgets/router.dart.

When pop should not call _handleRouteInformationProviderNotification otherwise will be path wrong.
because the value of GoRouteInformationProvider is not the latest.

Solution:

always make the value of GoRouteInformationProvider knew the latest RouteInformation[but not to do notifyListeners()].

i don't know if adding pop to NavigatingType is reasonable, if any place needs to be changed please tell me.

Result:

After changed, the issue been solved and all the others pop not be affect such as drawer/dialog/bottomsheet, See the video below.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I linked to at least one issue that this PR fixes in the description above.

flutter/flutter#150312

exempt from version changes

this PR is exempt from CHANGELOG changes.

  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.

this PR is test-exempt.

  • All existing and new tests are passing.

the go_route_test.dart will error if testWidgets('throw if redirect to itself')[I have this problem when I pull the online branch. it's not relate this PR, All of the others test success, So I view this as all test cases successfully passing.]

Exception has occurred.
_AssertionError ('package:go_router/src/parser.dart': Failed assertion: line 110 pos 18: '!matchList.last.route.redirectOnly': A redirect-only route must redirect to location different from itself.
 The offending route: GoRoute#0ae4e(name: null, path: "route", Redirect Only))

@ahyangnb ahyangnb requested a review from chunhtai as a code owner December 28, 2024 07:57
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@ahyangnb
Copy link
Author

example code:
packages/packages/go_router/example/lib/stream_listener_router.dart

which contain test pop the drawer/dialog/bottomsheet.

@ahyangnb ahyangnb changed the title [Go Router] fix Popping state and re-rendering scaffold at the same time doesn't update the URL on web [new] [go_router] fix Popping state and re-rendering scaffold at the same time doesn't update the URL on web [new] Dec 28, 2024
@ahyangnb
Copy link
Author

after_changed

after_changed.MP4

@ahyangnb
Copy link
Author

before_change

before_change.MP4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant