您可以使用PageView。
PageController pageController = PageController(initialPage: 0);
int _selectedIndex = 0;
void _selectCurrentTab(int index) {
setState(() {
_selectedIndex = index;
});
pageController.animateToPage(_selectedIndex,
duration: Duration(milliseconds: 250), curve: Curves.linear);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: ...,
body: PageView(
pageSnapping: true,
controller: pageController,
children: [HomePage(), AboutPage()],
),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(...),
BottomNavigationBarItem(...)
],
type: BottomNavigationBarType.fixed,
showUnselectedLabels: true,
currentIndex: _selectedIndex,
onTap: _selectCurrentTab,
)));
}