MethodChannelFlutterBadgeController class

Implementation of FlutterBadgeControllerPlatform using MethodChannel.

This class communicates with the native platform (Android/iOS) through the flutter_badge_controller method channel.

  • On iOS, it uses:

    • UIApplication.shared.applicationIconBadgeNumber
  • On Android, it sends a broadcast intent (android.intent.action.BADGE_COUNT_UPDATE) which is supported by many OEM launchers (Samsung, Huawei, Xiaomi, etc.). Note: Not all Android launchers support app icon badges.

Example:

await FlutterBadgeController.setBadgeCount(5);   // show badge "5"
await FlutterBadgeController.getBadgeCount();    // returns 5
await FlutterBadgeController.clearBadge();       // reset badge to 0
Inheritance

Properties

hashCode int
The hash code for this object.
no setterinherited
methodChannel MethodChannel
The method channel used to communicate with native code.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearBadge() Future<void>
Clears the app icon badge (sets it to 0).
override
getBadgeCount() Future<int?>
Gets the current badge count from the app icon.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setBadgeCount(int count) Future<void>
Sets the app icon badge count.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited