【发布时间】:2018-12-20 08:51:42
【问题描述】:
我正在寻找打开页面时单击颤动中的BottomNavigationBarItem 中的图标。
我尝试了索引,但我无法理解是我将所有图标都放在一个列表中,然后如何获取它。
class CustomAppBar extends StatelessWidget {
final List<BottomNavigationBarItem> bottomBarItems = [];
final bottomNavigationBarItemStyle = TextStyle(fontStyle:
FontStyle.normal, color: Colors.black);
CustomAppBar() {
bottomBarItems.add(
BottomNavigationBarItem(icon: Icon(Icons.home,color: Colors.brown,),
title: Text("Explore", style:
bottomNavigationBarItemStyle.copyWith(color: Colors.green)),
),
);
bottomBarItems.add(new BottomNavigationBarItem(icon: new
Icon(Icons.favorite,color: Colors.black,),
title: Text("Watchlist",style: bottomNavigationBarItemStyle,),
),
);
bottomBarItems.add(new BottomNavigationBarItem(icon: new
Icon(Icons.local_offer,color: Colors.black,),
title: Text("Deals",style: bottomNavigationBarItemStyle,),
),
);
bottomBarItems.add(new BottomNavigationBarItem(icon: new
Icon(Icons.notifications,color: Colors.black,),
title: Text("Notifications",style: bottomNavigationBarItemStyle,),
),
);
}
@override
Widget build(BuildContext context) {
return Material(
elevation: 15.0,
child: BottomNavigationBar(
items: bottomBarItems,
type: BottomNavigationBarType.fixed,
),
);
}
}
/*class NewPage extends StatelessWidget {
String title;
NewPage(this.title);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text(title),),
);
}
}*/
【问题讨论】:
标签: android dart flutter flutter-layout