flutter_badge_manager_platform_interface 0.0.2
flutter_badge_manager_platform_interface: ^0.0.2 copied to clipboard
A common platform interface for the flutter_badge_manager plugin.
flutter_badge_manager_platform_interface #
Common platform interface for the flutter_badge_manager family of plugins.
This package defines the abstract API used by:
- Foundation (iOS / macOS) implementation
- Android implementation
- Any future (custom) implementations
Interface #
Extend FlutterBadgeManagerPlatform and set your implementation as default:
class MyBadgeManager extends FlutterBadgeManagerPlatform {
@override
Future<bool> isSupported() async => /* platform check */;
@override
Future<void> update(int count) async { /* apply badge */ }
@override
Future<void> remove() async { /* remove badge */ }
}
Registration (typically in your plugin's registerWith or static init):
FlutterBadgeManagerPlatform.instance = MyBadgeManager();
The provided MethodChannel implementation (MethodChannelFlutterBadgeManager) is used as the default on supported platforms.
Methods #
isSupported()→boolupdate(int count)(count >= 0)remove()
Negative counts must throw a PlatformException with code invalid_args.
Adding a new platform implementation #
- Create a new package (e.g.
flutter_badge_manager_windows). - Depend on
flutter_badge_manager_platform_interface. - Implement
FlutterBadgeManagerPlatform. - Set
FlutterBadgeManagerPlatform.instanceto your class during plugin registration.
Breaking changes #
Avoid breaking the interface. Prefer adding new optional methods with sensible fallbacks. See Flutter guidance: https://flutter.dev/go/platform-interface-breaking-changes
License #
BSD 3-Clause (see LICENSE).