quinzo
quinzo

Reputation: 689

Using hero animation with GetX Flutter

Does anybody have experience using the Hero animation with the GetX Route-Managment? I followed the instructions in https://docs.flutter.dev/development/ui/animations/hero-animations and use Get.toNamed()to navigate between my routes but it doesn't work.

Upvotes: 0

Views: 1338

Answers (1)

Gwhyyy
Gwhyyy

Reputation: 9166

I've been using Getx for quite some time, and I don't suggest trying to get the hero animations with Getx's route manager, because the Hero widget can link two widgets with the same tag using a HeroControllerScope, which is an InheritedWidget.

the InheritedWidget can be found in a place by the BuildContext where it's looked up.

and Getx break this rule, the Get.to() and Get.toNamed() navigate to new screens using a pre-set BuildContext.

so this will only get you into trouble, instead, think about using the Navigator widget with a BuildContext, to get Hero animations executing fine.

Upvotes: 6

Related Questions