0

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.

quinzo
  • 580
  • 2
  • 6
  • 21

1 Answers1

3

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.

Gwhyyy
  • 7,554
  • 3
  • 8
  • 35