Reputation: 392
Hi there everyone I have a question very similar to this: Flutter Hero-like transition in PageView
I think the difference is this question has a little more background.
We have a horizontal scrolling site with PageView and we want to animate the icon between both pages. Kind of like this: https://flutter.dev/docs/development/ui/animations/hero-animationsThing.
The thing is, most tutorials with HeroAnimations use
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {
return
Do you suggest we just rebuild the page so that it has this Navigator push? I think that would entail implementing gesture detectors to make it feel like a PageView and also custom transitions.
You can see our rough draft at https://teamcrushing.it
Page view just makes it so simple but perhaps we need to make our own PageView to get this functionality.
Upvotes: 4
Views: 2773
Reputation: 3396
There’s a package on pub.dev named coast
that provides hero-like animations for a page view.
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: 7
Reputation: 1153
In some cases, it might be more practical to switch to a pages structure, but incase you couldn't we can implement our own hero navigation animation. However it might not be as efficient as the hero animation, but in a nutshell to create such animation with the most basic functionality we will need to implement 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: 2