flutter_badge_controller 0.0.1 copy "flutter_badge_controller: ^0.0.1" to clipboard
flutter_badge_controller: ^0.0.1 copied to clipboard

A simple Flutter plugin to manage app icon badge (set, clear) for Android and iOS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_badge_controller/flutter_badge_controller.dart';

/// Example app demonstrating usage of `flutter_badge_controller`.
///
/// This simple Flutter app shows how to:
/// - Set the app icon badge count
/// - Clear the app icon badge
///
/// The app consists of two buttons:
/// 1. "Set Badge to 5" → sets the badge count to 5.
/// 2. "Clear Badge" → resets the badge count to 0.
///
/// Supports both iOS and Android (with launcher restrictions on Android).
void main() {
  runApp(const MyApp());
}

/// Main application widget
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              /// Button to set the badge count to 5
              ElevatedButton(
                onPressed: () async {
                  await FlutterBadgeController.setBadgeCount(5);
                },
                child: const Text("Set Badge to 5"),
              ),

              /// Button to clear the badge
              ElevatedButton(
                onPressed: () async {
                  await FlutterBadgeController.clearBadge();
                },
                child: const Text("Clear Badge"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
107
downloads

Publisher

unverified uploader

Weekly Downloads

A simple Flutter plugin to manage app icon badge (set, clear) for Android and iOS.

Repository (GitHub)
View/report issues

Topics

#badge #app-badge #flutter #android #ios

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_badge_controller

Packages that implement flutter_badge_controller