When you swipe vertically, image is dragged towards the swipe, with fading out animation of black background.
And after release, it smoothly returns to it’s previous position on the screen, like Hero animation does.
How is it possible to recreate such an effect using Flutter? The same scenario, in fullscreen photo view.
photo_view package is desired for fullscreen, so it shouldn’t interfere with zooming.
2
Answers
I found the solution. To create such an animation, you should use extended_image package, which has
SlideOutPage
widget for creation of such transitions.What you need is actually an out-of-the-box widget, and it’s surprisingly easy to use. It’s called
Hero
. Basically, you wrap the widget you want to animate like that in aHero
widget, with a specifictag
string, and, when you navigate to another screen, you wrap the destination widget in anotherHero
with the same tag. An effect like the one you shared can be achieved by wrapping two widgets with the same photo withHero
es in differentPageRoute
s.Check out this Flutter widget of the week video to get you started, and this Flutter.dev article for a more detailed explanation on
Hero
widgets.Edit: I see you are looking for a more specific image-viewer behavior. Then, I suggest you use the photo_view package, which includes many functionalities to visualize images, including the hero transition with swipe-dow-to-dismiss behaviors, pinching to zoom, etc.