【发布时间】: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