The PageController
of a PageView
has a function animateToPage
which allows to define the curve effect during page swipe.
Future<void> animateToPage(
int page, {
@required Duration duration,
@required Curve curve,
})
I need to match it's behavior with that of the default swipe transition of PageView.
Any help?
You can use a PageController to control which page is visible in the view. In addition to being able to control the pixel offset of the content inside the PageView, a PageController also lets you control the offset in terms of pages, which are increments of the viewport size.
CurvedAnimation class Null safety. An animation that applies a curve to another animation. CurvedAnimation is useful when you want to apply a non-linear Curve to an animation object, especially if you want different curves when the animation is going forward vs when it is going backward.
As mentioned by @pskink in the comments, the default PageView
transition animation relies on the physics applied by the user's gesture. Depending on the user's swipe, it's then translated to the page's transition animation.
On the other hand, PageController
's animateToPage
relies on the duration set and curve. To emulate a smooth swipe, you can use Curves.ease
as previously mentioned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With