v1.0.3
bottom_navigation_badge
BottomNavigationBadge 是由 westdabestdb 開發的 Flutter 小部件,允許開發者向底端導航列項目新增通知徽章。
63喜歡 169近 30 天下載40Pub 分數
平台暫無資料
westdabestdb/bottom_navigation_badge open-source repository details.
{"sdk":"flutter"}{"sdk":"flutter"}以下為英文專案原文快照,最新內容請造訪 GitHub。
BottomNavigationBadge is a Flutter class developed by westdabestdb.
https://media.giphy.com/media/42vZBDJcxd97IHro95/giphy.gif
Add this to your package's pubspec.yaml file:
...
dependencies:
bottom_navigation_badge: ^1.0.3
Now in your Dart code, you can use:
import 'package:bottom_navigation_badge/bottom_navigation_badge.dart';
Initialize the badger. Isn't it a nice variable name lol 😁
BottomNavigationBadge badger = new BottomNavigationBadge(
backgroundColor: Colors.red,
badgeShape: BottomNavigationBadgeShape.circle,
textColor: Colors.white,
position: BottomNavigationBadgePosition.topRight,
textSize: 8);
Create a list of BottomNavigationBarItems
List<BottomNavigationBarItem> items = [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("Home")),
BottomNavigationBarItem(icon: Icon(Icons.notifications), title: Text("Notifications")),
BottomNavigationBarItem(icon: Icon(Icons.face), title: Text("Profile"))
];
Add badge to index with content "1"
setState(() {
items = badger.setBadge(items, "1", index);
});
Remove the badge at index
setState(() {
items = badger.removeBadge(items, index);
});
Remove all the badges
setState(() {
items = badger.removeAll(items);
});