flutter_native_badge 1.0.5+dev copy "flutter_native_badge: ^1.0.5+dev" to clipboard
flutter_native_badge: ^1.0.5+dev copied to clipboard

PlatformiOSmacOS

Flutter plugin for setting the badge count on native platforms. Wraps the native APIs for iOS and macOS to set the badge count on the app icon.

flutter_native_badge #

Wrapper for native badge APIs on iOS and macOS. It allows you to change the badge of your app icon, by setting the count, showing red dot, clearing the badge and getting the current badge count.

It supports iOS and macOS for now. Other platforms are not supported yet.

Preview #

Ios App MacOs App

Usage #

Before using any of the methods, you should check if the platform is supported. If not, the methods will throw an unsupported exception.

Each method will check if the permission is granted if you set the requestPermission parameter to true. If not, it will not request the permission and the method may not work if the permission is not granted.

Import #

import 'package:flutter_native_badge/flutter_native_badge.dart';
copied to clipboard

Check if the platform is supported #

bool isSupported = await FlutterNativeBadge.isSupported();
copied to clipboard

Set badge count #

FlutterNativeBadge.setBadgeCount(5);
copied to clipboard

Show red dot #

FlutterNativeBadge.showRedDot();
copied to clipboard

Clear badge count #

FlutterNativeBadge.clearBadgeCount();
copied to clipboard

Get badge count #

int badgeCount = await FlutterNativeBadge.getBadgeCount();
copied to clipboard

For iOS: getBadgeCount depends on deprecated API and could be unavailable in future iOS releases! There aren't any replacements in iOS SDK. If you use getBadgeCount now, you had better to consider how to manage the count yourself.

Request permission #

Each method has a requestPermission parameter. If you set it to true, it will request the permission if it is not granted.

FlutterNativeBadge.setBadgeCount(5, requestPermission: true);

FlutterNativeBadge.showRedDot(requestPermission: true);

FlutterNativeBadge.clearBadgeCount(requestPermission: true);

int badgeCount = await FlutterNativeBadge.getBadgeCount(requestPermission: true);
copied to clipboard

Contributing #

Contributions are welcome! Please follow the Flutter & Dart standard and make a PR.

18
likes
150
points
149
downloads

Publisher

unverified uploader

Weekly Downloads

2024.08.27 - 2025.03.11

Flutter plugin for setting the badge count on native platforms. Wraps the native APIs for iOS and macOS to set the badge count on the app icon.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_native_badge_foundation, flutter_native_badge_platform_interface

More

Packages that depend on flutter_native_badge