letsar / local_hero

A widget which implicitly launches a hero animation when its position changed within the same route.
MIT License
209 stars 48 forks source link

Would be great to have a callback on animationEnded #10

Open FrankDomburg opened 2 years ago

FrankDomburg commented 2 years ago

Sometimes, I want to do stuff after the local heroes are done animating.

Current flow is that I change the inflightbuilder to add False to an array, whenever a local hero starts animating, and to add True to the same array when the status is animationStatus == completed. Whenever the number of True == number of False, I do what I want to do next.

Does it make sense for the LocalHeroController to provide a callback to do, I guess that would be way more efficient than a bunch of setState commands?

martipello commented 2 years ago

@FrankDomburg created a PR for this, the callback is slightly delayed by about 300 milliseconds but works great otherwise, but looking at the other PRs that havent been merged it may be better to create a new package and just link back to this

martipello commented 2 years ago

i published my fork with the added callback here https://pub.dev/packages/local_hero_with_callback