Skip to content

[go_router] Fixes crashes when popping navigators manually #2952

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

Merged
merged 3 commits into from
Jan 4, 2023

Conversation

chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Dec 15, 2022

fixes flutter/flutter#116784
fixes flutter/flutter#116769
fixes flutter/flutter#117431

The issue is that the app bar will pop the root navigator and skipping the navigator in the shellroute, and the goRouter only expect the RouteMatchList to be popped start from the last RouteMatch. This pr fixes it so that it can handle the case where developer may manually pop any navigator.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki 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 listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • 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.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -16,7 +16,7 @@ import 'typedefs.dart';

/// GoRouter implementation of [RouterDelegate].
class GoRouterDelegate extends RouterDelegate<RouteMatchList>
with PopNavigatorRouterDelegateMixin<RouteMatchList>, ChangeNotifier {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed this when we refactor the pop. PopNavigatorRouterDelegateMixin is no longer needed since we override poproute directly

@@ -1012,6 +1012,80 @@ void main() {
]);
});

testWidgets('Can manually pop root navigator and display correct url',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a test case that pop multiple times?
I think this PR would fix flutter/flutter#117431 but just want to make sure of it.

I added a test case for it in this PR: #2989 but since it's close, I'd like to add it in this PR at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added on pop twice

Copy link

@leehack leehack Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ;)
I have no right to approve the PR but everything looks good to me.

@leehack
Copy link

leehack commented Dec 21, 2022

#2989 could be added to the issue list since it's a potential fix for it as well.

@chunhtai
Copy link
Contributor Author

looks like this is blocked on #2977

@devberkay
Copy link

This issue is also fixed with this pr.

@chunhtai chunhtai merged commit 3ef0f63 into flutter:main Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants