flutter_local_notification_plus
Enhanced local notifications with rich media, actions, and scheduling for Flutter.
Version 0.1.0 - Enhanced local notifications with perfect code quality! π
β¨ What's New in 0.1.0
- π― Notification Grouping - Full support for grouped notifications on iOS and Android
- π Perfect Pana Score - Achieved 160/160 points with zero static analysis issues
- π Enhanced Documentation - Comprehensive library-level documentation for better API discoverability
- π·οΈ Package Topics - Added topics for better discoverability on pub.flutter-io.cn
- π° Funding Support - Added GitHub Sponsors funding link
- π§ Improved Compatibility - Updated SDK constraints and fixed iOS version compatibility
- π Bug Fixes - Fixed permission handling, notification display, and BuildContext usage
Demo
Features
- π― Rich Media Support: Display images, videos, and audio in notifications
- β‘ Advanced Actions: Custom notification actions and responses
- π Flexible Scheduling: Schedule notifications with precise timing (one-time, recurring, interval-based)
- π Cross-Platform: Works on iOS, Android, macOS, Windows, Linux, and Web
- π¨ Customizable: Extensive styling and appearance options
- π‘οΈ Permission Handling: Built-in permission management
- π± Badge Management: App badge support and management
- π¦ Notification Grouping: Group related notifications together (iOS & Android)
- π WASM Ready: WebAssembly compatibility for modern web apps
- β¨ Perfect Code Quality: 160/160 pana score with zero static analysis issues
Getting Started
Installation
Add this to your package's pubspec.yaml file:
dependencies:
flutter_local_notification_plus: ^0.1.0
Basic Usage
import 'package:flutter_local_notification_plus/flutter_local_notification_plus.dart';
// Initialize the plugin
await FlutterLocalNotificationPlus.initialize();
// Show a simple notification
await FlutterLocalNotificationPlus.showNotification(
id: 1,
title: 'Hello!',
body: 'This is a notification',
);
// Schedule a notification
await FlutterLocalNotificationPlus.scheduleNotification(
id: 2,
title: 'Scheduled',
body: 'This notification was scheduled',
scheduledDate: DateTime.now().add(Duration(minutes: 5)),
);
Advanced Features
Rich Media Notifications
final options = {
'icon': '/path/to/image.png',
'badge': '1',
'tag': 'media_notification',
};
await FlutterLocalNotificationPlus.showNotification(
id: 3,
title: 'Rich Media',
body: 'Check out this image!',
options: options,
);
Custom Actions
final options = {
'actions': ['accept', 'decline'],
'sound': 'custom_sound.mp3',
'vibration': true,
};
await FlutterLocalNotificationPlus.showNotification(
id: 4,
title: 'Action Required',
body: 'Please respond to this notification',
options: options,
);
Scheduling Options
// Schedule for specific time
await FlutterLocalNotificationPlus.scheduleNotification(
id: 5,
title: 'Meeting Reminder',
body: 'Team meeting in 30 minutes',
scheduledDate: DateTime.now().add(Duration(minutes: 30)),
);
// Schedule recurring notification (every minute)
await FlutterLocalNotificationPlus.scheduleNotification(
id: 6,
title: 'Recurring Reminder',
body: 'This repeats every minute',
scheduledDate: DateTime.now().add(Duration(seconds: 5)),
options: {
'repeatInterval': 'minute', // minute, hour, day, week
},
);
// Schedule with custom interval (every 10 seconds)
await FlutterLocalNotificationPlus.scheduleNotification(
id: 7,
title: 'Interval Notification',
body: 'This repeats every 10 seconds',
scheduledDate: DateTime.now().add(Duration(seconds: 2)),
options: {
'interval': 10.0, // seconds
},
);
Notification Grouping
// Android: Group notifications together
await FlutterLocalNotificationPlus.showNotification(
id: 10,
title: 'Message from Alice',
body: 'Hey, how are you?',
options: {
'groupKey': 'messages', // Same group key groups them together
},
);
// Group summary notification (Android)
await FlutterLocalNotificationPlus.showNotification(
id: 0,
title: 'Messages',
body: 'You have 3 new messages',
options: {
'groupKey': 'messages',
'isGroupSummary': true,
'summaryText': '3 new messages',
},
);
// iOS: Use threadId for grouping
await FlutterLocalNotificationPlus.showNotification(
id: 11,
title: 'Message from Bob',
body: 'Can we meet tomorrow?',
options: {
'threadId': 'messages', // Groups notifications by thread
'summary': '3 new messages', // Summary text for grouped notifications
},
);
Platform Support
| Platform | Status | Features |
|---|---|---|
| Android | β Full Support | All features available |
| iOS | β Full Support | All features + SPM support |
| macOS | β Full Support | All features + SPM support |
| Windows | β Full Support | All features available |
| Linux | β Full Support | All features available |
| Web | β Full Support | WASM compatible + browser APIs |
Configuration
Android
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
iOS
Add the following to your ios/Runner/Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
Web
For web applications, the plugin automatically handles browser notification permissions and APIs. No additional configuration is required.
API Reference
Core Methods
initialize()- Initialize the notification pluginshowNotification()- Display a notification immediatelyscheduleNotification()- Schedule a notification for latercancelNotification()- Cancel a specific notificationcancelAllNotifications()- Cancel all notificationsgetPendingNotifications()- Get list of pending notificationsareNotificationsEnabled()- Check if notifications are enabledrequestPermissions()- Request notification permissions
Options
icon- Custom notification iconbadge- Badge number to displaytag- Unique identifier for the notification (Web)sound- Custom sound filevibration- Enable/disable vibration (Android)actions- Array of action buttonsimage- Image attachment for rich media notificationsvideo- Video attachment (iOS)audio- Audio attachment (iOS)groupKey- Group key for Android notification groupingisGroupSummary- Mark as group summary notification (Android)summaryText- Summary text for group summary (Android)threadId- Thread identifier for iOS notification groupingsummary- Summary text for iOS grouped notificationsrepeatInterval- Recurring interval: 'minute', 'hour', 'day', 'week'interval- Custom interval in seconds for recurring notifications
Technical Architecture
Native Platforms
- Custom method channel implementation
- Platform-specific notification APIs
- Optimized performance with native code
Web Platform
- Browser notification APIs
- WASM-compatible implementation
- No
dart:iodependencies
Swift Package Manager
- Native iOS and macOS support
- Package.swift configuration
- Full integration with Apple ecosystem
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
Changelog
See CHANGELOG.md for a list of changes and version history.
Libraries
- flutter_local_notification_plus
- Enhanced local notifications with rich media, actions, and scheduling for Flutter.
- flutter_local_notification_plus_web
- Web plugin implementation for Flutter Local Notification Plus.