底部导航
~
int _counter = 0;
var titles = [“首页”, “聊天”, “发现”, “我的”];
int _selectedIndex = 0;
String badgeNo1 = ‘3’;/// icon数组
var icons = [
Icons.home,
Icons.chat_bubble,
Icons.find_in_page,
Icons.account_circle_outlined,
];
List_getTabBarItems({int count = 1}) {
return List.generate( count, (index) => BrnBottomTabBarItem( icon: Icon( icons[0], color: Colors.grey, ), title: Text(titles[0]), activeIcon: Icon( icons[0], color: Colors.green, ), selectedTextStyle: TextStyle(color: Colors.green), unSelectedTextStyle: TextStyle(color: Colors.green), ));
}
void _onItemSelected(int index) {
switch (index) {case 0: BrnToast.show("首页", context); break; case 1: BrnToast.show("聊天", context); break; case 2: BrnToast.show("发现", context); break; case 3: BrnToast.show("我的", context); break;
}
setState(() {/// 置为当前选中item的索引值 _selectedIndex = index; /// 选中后未读消息的数量 badgeNo1 = '';
});
}
BrnBottomTabBar(
fixedColor: Colors.green,
currentIndex: _selectedIndex,
onTap: _onItemSelected,
badgeColor: Colors.red,
type: BrnBottomTabBarDisplayType.fixed,
items:
BrnBottomTabBarItem(icon: Icon(icons[0]), title: Text(titles[0])),
BrnBottomTabBarItem(icon: Icon(icons[1]), title: Text(titles[1])),
BrnBottomTabBarItem(icon: Icon(icons[2]), title: Text(titles[2])),
BrnBottomTabBarItem(
icon: Icon(icons[3]), title: Text(titles[3]), badgeNo: badgeNo1),
],
),~
更新时间:2024-12-05 13:26