效果图:

BottomNavigationBar
先来看一下官方的sample code:
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 1;
final _widgetOptions = [
Text('Index 0: Home'),
Text('Index 1: Business'),
Text('Index 2: School'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BottomNavigationBar Sample'),
),
body: Center(
child: _widgetOptions.elementA

这篇博客介绍了如何在Flutter中使用BottomNavigationBar结合PageView.builder和PageController实现底部导航栏与页面滑动切换的功能。通过定义页面数组、设置PageView及监听onPageChanged事件,实现了点击和滑动切换不同内容的效果。
订阅专栏 解锁全文
3388

被折叠的 条评论
为什么被折叠?



