Skip to content

[go_router] [shell_route] Add observers parameter #2664

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 12 commits into from
Feb 14, 2023

Conversation

angjelkom
Copy link
Contributor

@angjelkom angjelkom commented Sep 30, 2022

This PR adds observers parameter to the ShellRoute and passes that to the nested Navigator created by that same ShellRoute.

The need for this PR is because it fixes cases where a Hero animation doesn't work when used with nested navigation and it requires a HeroController to be used as an observer for that nested Navigator.

fixes flutter/flutter#112095

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.

@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 to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

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.

Copy link

@grimatoma grimatoma left a comment

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai self-requested a review October 13, 2022 21:46
@chunhtai
Copy link
Contributor

Hi @angjelkom , are you still planning to work on this pr?

@angjelkom
Copy link
Contributor Author

angjelkom commented Nov 11, 2022

Hi @angjelkom , are you still planning to work on this pr?

Apologize, yes I will add your suggested change over the weeekend. I've been busy with work.

@angjelkom
Copy link
Contributor Author

@chunhtai I will need a bit more time, as merging the latest commits from the main branch caused my example to have weird side-effects where the Hero animation doesn't work when going to the next page but when going back it works in a buggy-weird way.

So until i solve that I can't commit the change for HeroControllerScope.

@angjelkom angjelkom force-pushed the shell-route-observers branch from efd5ca8 to 4011341 Compare November 14, 2022 20:01
@chunhtai
Copy link
Contributor

@angjelkom are still planning on coming back to this pr?

@angjelkom
Copy link
Contributor Author

@chunhtai Sorry I am too busy at the moment with work, I will for sure complete it by the end of next week!

@angjelkom
Copy link
Contributor Author

@chunhtai I can't complete the pull request until #115832 its fixed, its blocking me.

I could use a lower commit but still I would need to test it against the latest commit at the end and currently that's not possible because of the above issue.

@chunhtai
Copy link
Contributor

chunhtai commented Dec 6, 2022

@angjelkom I will take a look at the issue and try to resolve it asap

@ycherniavskyi
Copy link
Contributor

@angjelkom, the issue you mentioned has been fixed. Could you update your PR for merging? If you are too busy, I could create an analogic PR. I need it solely for FirebaseAnalyticsObserver.

@angjelkom
Copy link
Contributor Author

@ycherniavskyi yes saw the merge today, I will proceed with completing the PR

@angjelkom angjelkom force-pushed the shell-route-observers branch 4 times, most recently from 4b28692 to f11123d Compare December 8, 2022 19:31
@angjelkom
Copy link
Contributor Author

@ycherniavskyi the PR is ready waiting for @chunhtai to review it and approve it.

@angjelkom angjelkom force-pushed the shell-route-observers branch from f11123d to 915f6b2 Compare December 9, 2022 08:01
@arsen
Copy link

arsen commented Dec 13, 2022

any chance this will get merged soon?

@angjelkom
Copy link
Contributor Author

@arsen I will get on it tonight to finish it up.

@angjelkom
Copy link
Contributor Author

@chunhtai as @ycherniavskyi suggested we should use the relevant HeroController based on whether MaterialApp or CupertinoApp is used, in order to do that we need to use the RouteBuilder not the ShellRoute in order to access the context.

The issue is because the RouteBuilder gets rebuild while navigating the HeroController which again breaks the animation, the way I see it we have two options:

Option 1:

Create 3 final variables in the RouteBuilder, one using createMaterialHeroController, one using createCupertinoHeroController and a default HeroController.
Then we can use those to pass the correct controller.
This way the controllers won't be rebuild and the animation would work. (tested)

Option 2:

Have a heroController parameter to the ShellRoute so that the user passes one himself.

Let me know what would you recommend, I can do the change tonight.

@ycherniavskyi
Copy link
Contributor

As I understand, the last barrier before merging is extending the hero controller test. @chunhtai am I correct?

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

Sorry I just got back from vacation.

@chunhtai
Copy link
Contributor

chunhtai commented Feb 1, 2023

As I understand, the last barrier before merging is extending the hero controller test. @chunhtai am I correct?

correct

@kamami
Copy link

kamami commented Feb 4, 2023

When will this be merged?

@chunhtai
Copy link
Contributor

chunhtai commented Feb 9, 2023

Hi @angjelkom, it looks like @flodaniel has provided a test, can you commit to this pr so that i can merge it?

@angjelkom angjelkom force-pushed the shell-route-observers branch from 516bfef to 544fd68 Compare February 10, 2023 08:46
@angjelkom angjelkom force-pushed the shell-route-observers branch from 544fd68 to c34d480 Compare February 10, 2023 08:54
@angjelkom
Copy link
Contributor Author

@flodaniel Thanks a lot for the test! @chunhtai merged it, but at the moment submit-queue check is failing for some other reason.

@chunhtai chunhtai requested a review from hannah-hyj February 13, 2023 16:38
Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

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

LGTM

@lublot
Copy link

lublot commented Feb 14, 2023

Hello everyone! Is there any prediction of when it will be merged?

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 14, 2023
@auto-submit auto-submit bot merged commit 278b489 into flutter:main Feb 14, 2023
auto-submit bot pushed a commit that referenced this pull request Dec 7, 2023
…ng a `ShellRoute` with `observers` (#5563)

[This pr](#2664) added the ability to provide a list of `NavigatorObservers` to a `ShellRoute`.  The equivalent was never added to `go_router_builder`, so this pr provides that functionality.

This is a workaround to [this issue](flutter/flutter#112196) where navigator observers added to a `GoRouter` at the top level do not fire in `ShellRoutes`.  With this change, you can provide `NavigatorObservers` directly to the `ShellRoute`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App needs tests p: go_router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[go_router] Hero animation don't work between pages nested on ShellRoute