In a Scaffold page with something like the following structure
@override
Widget build(BuildContext context){
body: PageView(
controller: _controller;
children: <Widget>[Page1(), Page2(), Page3()];
);
bottomNavigationBar: BottomNavBar(
onItemSelected: (index) => _controller.animateToPage()
)
}
there are two ways to go from Page2()
to Page1()
:
- Swipe the screen from left to right
- Tap the Page1() icon on the
bottomNavigationBar
, and thus calling_controller.animateToPage(0)
The problem is, how can I tell if the page is changed through swiping gesture or animateToPage()
function?
Thanks.