我需要导航抽屉和底部导航,所以我确实在项目中添加了自定义导航抽屉,也确实添加并显示了底部导航栏,但是我面临的问题是我只能显示它,但无法设置它的onTap功能并在页面之间导航。作为参考,我确实粘贴了示例代码。
class SideBarLayout extends StatelessWidget {
int _currentIndex = 0;
List<Widget> _tab_list =[
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: BlocProvider<NavigationBloc>(
create: (context) => NavigationBloc(),
child: Stack(
children: <Widget>[
BlocBuilder<NavigationBloc, NavigationStates>(
builder: (context, navigationState) {
return navigationState as Widget;
},
),
SideBar(),
]
),
),
bottomNavigationBar: BottomNavigationBar(
onTap: (currentIndex){
_currentIndex = currentIndex;
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
backgroundColor: Color(0xFF478DE0),
),
BottomNavigationBarItem(
icon: Icon(Icons.assignment),
title: Text('Quotation'),
backgroundColor: Color(0xFF478DE0),
),
BottomNavigationBarItem(
icon: Icon(Icons.attach_money),
title: Text('Payments'),
backgroundColor: Color(0xFF478DE0),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text('Profile'),
backgroundColor: Color(0xFF478DE0),
),
],
),
);
}
}