onPressed: () async {
if (pageController != null) {
if (pageController.page != 3) {
pageController = await pageController.nextPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeOut) as PageController;
}
} else {
Navigator.of(context).pushNamed(WelcomeScreen.routeName);
}
},
Tried a lot to fix this but end up with nothing, if anyone could help. Thanks.
CodePudding user response:
You have a mistake here
pageController = await pageController.nextPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeOut) as PageController;
The method pageController.nextPage
does not return a PageController. In fact it returns nothing, it is a void method. And this is why the cast as PageController
is failing. To put it simple: You cannot convert nothing (void) into something (PageController)
Therefore, you should replace the above line with just
await pageController.nextPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeOut);