Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default Curve behavior for PageView in Flutter?

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?

like image 683
pso Avatar asked May 22 '19 05:05

pso


People also ask

How does PageView work in flutter?

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.

WHAT IS curve animation in flutter?

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.


1 Answers

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.

like image 79
Omatt Avatar answered Oct 10 '22 07:10

Omatt