Reputation: 71
I have an image in one page of the PageView. I want to animate this image to the next page when i go to it, sort of like when you use Hero animations in navigator page transitions. Any ideas how this can be achieved?
Upvotes: 7
Views: 1905
Reputation: 3386
This packages does what you want https://pub.dev/packages/coast
It is essentially taking the same approach as Flutter’s Hero and HeroController: Detect when a transition is started, search through the element trees of the source and target pages for the widgets marked for animation (heroes, crabs), pair them up based on their tags, and finally create an entry in an Overlay whose position and size is the interpolation between those on the source and target pages.
Upvotes: 1
Reputation: 1143
In order to achieve an animation similar to the hero animation. Basically what we will implement is this, you will need 5 elements:
Now in order to create this animation that spans the 2 screens we will need to use the overlay that is present in flutter. link
This is the most flexible between all of the available options since you have access to the widget in all of its states. However you must be very careful when using this method as it might cause a slowdown if not properly implemented.
Upvotes: 1