PageView PageController losing clients

Viewed 146

I have a PageView widget with 2 children, on the first page there's a button where you can call a function, when it returns the PageView should be animated to the second page.

To do this i'm using this code:

if (pageController.hasClients) {
  pageController.animateToPage(
    1,
    duration: Duration(milliseconds: 200),
    curve: Curves.easeIn,
  );
}

But when calling this after the function returns, the pageController doesn't have any clients. I have tried placing a button to animate to the second page and pressing that right after the function is done, which works.

I don't understand why it works one place and not the other place..

0 Answers
Related