app_badger 3.1.1
app_badger: ^3.1.1 copied to clipboard
A Flutter plugin to manage app badge counts on Android, iOS, and macOS with modern Swift Package Manager and federated architecture support.
app_badger Flutter Plugin #
A Flutter plugin for app badge counts across Android, iOS, and macOS.
Attribution and third-party notice #
This project is an independent Flutter badge plugin developed for Android, iOS, and macOS. It is not a fork of, and does not include source code from, the upstream project at https://github.com/g123k/flutter_app_badger.
This package uses the following third-party component:
- ShortcutBadger for Android launcher badge support, licensed under the Apache License 2.0.
The project is distributed under the MIT License and retains all dependency license notices.
Version 3.1.1 #
- Monorepo support with Melos
- Distinct public API:
AppBadgeController,setBadgeValue,clearBadgeValue,getBadgeValue,requestBadgePermission - Compatibility wrappers remain available for older integrations
- Android, iOS, and macOS support
Installation #
Add to your pubspec.yaml:
dependencies:
app_badger: ^3.1.1
Then:
flutter pub get
Monorepo commands #
This repository uses Melos:
melos bootstrap
melos analyze
melos test
melos format
Required setup #
Android #
Add permissions in android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Optional launcher permissions for device-specific support may also be added depending on the target launcher.
iOS #
Add notification usage description to ios/Runner/Info.plist:
<key>NSUserNotificationUsageDescription</key>
<string>Notifications are required to display app badges</string>
macOS #
Dock badges work without extra entitlements or notification permission. Use the native Dock badge API directly.
Usage #
import 'package:app_badger/app_badger.dart';
Future<void> updateAppBadge() async {
await AppBadgeController.setBadgeValue(5);
}
Future<void> clearAppBadge() async {
await AppBadgeController.clearBadgeValue();
}
Future<void> requestPermission() async {
final granted = await AppBadgeController.requestBadgePermission();
print('Permission granted: $granted');
}
Event stream #
AppBadgeController.events.listen((event) {
print('Badge event: $event');
});
Android notification config #
AppBadgeController.setAndroidNotificationConfig(
channelId: 'app_badger_channel',
channelName: 'Badge updates',
smallIcon: 'ic_stat_notify_badge',
);
Recommended app startup flow #
Future<void> initializeBadges() async {
await AppBadgeController.requestBadgePermission();
final supported = await AppBadgeController.isFeatureSupported();
if (supported) {
await AppBadgeController.setBadgeValue(1);
}
}
Notes on risk and originality #
- This package intentionally uses distinct public API names to avoid confusion with other badge plugins.
- The implementation is maintained independently and is not presented as a fork or direct copy of the upstream project.
- If you publish this package, keep the attribution notice and dependency license notices with the source.
License #
MIT