扑底导航和抽屉

时间:2018-12-28 12:17:00

标签: flutter

 class HomePage extends StatefulWidget {
   @override
   _HomePageState createState() => _HomePageState();
 }

 class _HomePageState extends State<HomePage> {
 int _selectedIndex = 0;
 List<Widget>firstFlowpagesList=List();
 final bottomNavigationColor=const  Color(0xFF364195);

 @override
   void initState() {
     firstFlowpagesList
     ..add(HomeFragment())
     ..add(StylistPage())
     ..add(MyAppointmentsPage())
     ..add(HairtipsPage())
    ..add(AccountPage());
     super.initState();
   }
   @override
   Widget build(BuildContext context) {
   return Scaffold(
    //  appBar: AppBar(
    //    title: Text('BottomNavigationBar Sample'),
    //  ),
    //  body: Center(
    //    child: _widgetOptions.elementAt(_selectedIndex),

    //  ),
     body: firstFlowpagesList[_selectedIndex],
     bottomNavigationBar: BottomNavigationBar(
       type: BottomNavigationBarType.shifting,
       items: <BottomNavigationBarItem>[
         BottomNavigationBarItem(icon: Icon(Icons.home,color:bottomNavigationColor), title: Text('Home',style: TextStyle(color:bottomNavigationColor))),
         BottomNavigationBarItem(icon: Icon(Icons.business,color:bottomNavigationColor), title: Text('Business',style: TextStyle(color:bottomNavigationColor))),
         BottomNavigationBarItem(icon: Icon(Icons.school,color:bottomNavigationColor), title: Text('School',style: TextStyle(color:bottomNavigationColor))),
         BottomNavigationBarItem(icon: Icon(Icons.ac_unit,color:bottomNavigationColor),title: Text('Haitips',style: TextStyle(color:bottomNavigationColor))),
         BottomNavigationBarItem(icon: Icon(Icons.access_time,color:bottomNavigationColor),title: Text('Account',style: TextStyle(color:bottomNavigationColor))),
       ],
       currentIndex: _selectedIndex,
       fixedColor:const Color(0xFF364195),
       onTap: _onItemTapped,
     ),
   );
   }
    void _onItemTapped(int index) {
   setState(() {
     _selectedIndex = index;
   });
 }

 }

这是我的底部导航代码,我想在我的应用程序中实现抽屉和底部导航。如何在一个应用程序中同时实现。我知道如何实现android,但我不知道如何在flutter中执行相同的操作

1 个答案:

答案 0 :(得分:0)

我没有遇到要同时实现这两个问题的问题,这应该很简单。

Scaffold(
  drawer: Drawer(child: ListView(children: [...]), // You can use ListTile for children and handle onTap()
  bottomNavigationBar: BottomNavigationBar(...),
)