我在底部导航中创建了FloatingNavbar。我想在FloatingNavbar中的购物车图标的顶部购物车上添加徽章。当我尝试使用正常的bottomnavigation时,它可以正常工作,但是当我尝试使用FloatingNavbar时,无法正常工作。因为普通的底部导航图标是小部件,但是在FloatingNavbar中,它是icondata。这就是为什么它不起作用。有人可以帮我吗?
代码:
return new WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
backgroundColor: Colors.grey[300],
// appBar: HomeAppBar(),
extendBody: false,
body: _tabs[_selectedIndex],
bottomNavigationBar: FloatingNavbar(
currentIndex: _selectedIndex,
items: itemsFloating,
backgroundColor: Colors.white,
unselectedItemColor: Colors.grey[500],
fontSize: 8,
selectedItemColor: Colors.orange[300],
onTap: _onItemTapped,
),
),
);
List<FloatingNavbarItem> itemsFloating =[
FloatingNavbarItem(icon: Icons.home
, title: 'Home'),
FloatingNavbarItem(icon: Icons.search, title: 'Search'),
FloatingNavbarItem(icon: Icons.shopping_cart, title: 'Cart'),
FloatingNavbarItem(icon: Icons.people, title: 'Membership'),
FloatingNavbarItem(icon: Icons.person_outline, title: 'Profile'),
];
徽章:
icon: Badge(
showBadge: true,
badgeContent: Text(
badgeData,
style: TextStyle(color: Colors.white),
),
child: Icon(Icons.shopping_cart)),