【问题标题】:flutter bottom navigation and drawer颤动底部导航和抽屉
【发布时间】:2018-12-28 12:16:59
【问题描述】:
 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】:

    我没有得到你在实现这两个方面遇到的问题,它应该很简单。

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

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多