M812_
M812_

Reputation: 55

page transit animation control

I am creating a PageView section and it has around 5 - 10 children. I tried to make buttons to control the page flow.

IconButton(
    icon: const Icon(Icons.arrow_back_ios_new_rounded),
    onPressed: () {
        pageController.previousPage(
            duration: Duration(seconds:1), 
            curve: Curves.easeIn
        );
    }
)

Edit:
From flutter official documentation: Flutter - Duration class

Constructors
Duration({int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, int microseconds = 0}) Creates a new Duration object whose value is the sum of all individual parts.
const

Duration includes day/hour/minute/second/millisecond/microsecond as its units when constructing a Duration class object.

If you want the pageController to have a shorter duration while going to some pages, you should assign a Duration with a smaller unit.

Upvotes: 0

Views: 69

Answers (1)

Ardeshir ojan
Ardeshir ojan

Reputation: 2419

you can put it this way

pageController.previousPage(
        duration: Duration(milliseconds: 200), 
        curve: Curves.easeIn
    );

now it would take 0.2 secs to go next page

Upvotes: 2

Related Questions