csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 97 forks source link

Missing `HeroController` inheritance #314

Closed benPesso closed 2 years ago

benPesso commented 2 years ago

According to this article, if you're not using Navigator 1.0, Heros will essentially not work, as they rely on a HeroController provided by Navigator to conduct their transitions.

Took me a good while to figure out why Hero animations were not working with GoRouter, until I accidently stumbled on this little gem of an article - which I doubt many others are familiar with - and managed to get it working.

By wrapping with a HeroControllerScope widget: ```dart MaterialApp( home: HeroControllerScope( controller: HeroController(), child: Router( routerDelegate: _router.routerDelegate, routeInformationParser: _router.routeInformationParser, ), ), ... ); ```

Or...

by adding a HeroController observer: ```dart _router = GoRouter( observers: [HeroController()], ... ); ```

Ideally, GoRouter should include a HeroController observer by default (with option to override, for tween behavior modification). At the very least, the GoRouter > Transitions section should probably mention something about Hero animations and how to get them working with GoRouter.

csells commented 2 years ago

Cool! Would you like to propose a new sample that supports Hero graphics in a PR along with some updates to the docs?

benPesso commented 2 years ago

Yeah sure. Just need to iron out some kinks with Hero animation jitter first. 😶

csells commented 2 years ago

closing this due to lack of customer input. feel free to reopen it if you have a minimal repro.