1

我需要导航抽屉和底部导航所以我确实在我的项目中添加了一个自定义导航抽屉也添加并显示了底部导航栏但我面临的问题是我只能显示它但无法设置 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),
          ),
        ],
      ),
    );
  }
}
4

0 回答 0