How do I get the previous index in PageView onPageChanged? Currently, I can get the current index when the page changes with the following code:
PageView(
children: <Widget>[
SomeView(),
SomeOtherViews(),
SomeOtherViews(),
],
controller: _pageViewController,
onPageChanged: _onPageViewChange,
);
_onPageViewChange(int page) {
print("Current Page: " + page.toString());
}
Does flutter have any built-in function for this? Or should I just manually save the page as reference for the previous page?
- Yes I have thought of that, I just want to know if there's a faster way without having to create a variable