Easy Local Notify
Easy Local Notify is a Flutter package that allows you to send local notifications on Android, iOS, and Web platforms. It is simple to integrate, fully supports platform-specific notification features, and handles permissions automatically.
Features
- Local notifications for Android, iOS, and Web.
- Automatic permission request handling.
- Supports immediate and scheduled notifications.
- Minimal and clean API.
- Cross-platform support using conditional imports.
Installation
Add the dependency to your pubspec.yaml
:
dependencies:
easy_local_notify: ^0.0.1
Then run:
flutter pub get
Setup
Android
- Ensure your
minSdkVersion
inandroid/app/build.gradle
is at least21
. - Android 13+ requires notification permission.
EasyLocalNotify
automatically requests it. - Add the following to
AndroidManifest.xml
:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
iOS
- Open
ios/Runner/Info.plist
and add:
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>NSUserNotificationUsageDescription</key>
<string>We need notification permissions to show alerts.</string>
- The package automatically requests permissions for alert, sound, and badge.
Web
- Notifications require user permission. The package handles this automatically.
- Scheduling notifications on web is not supported; only immediate notifications are shown.
Usage
Initialize
import 'package:easy_local_notify/easy_local_notify.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalNotify.init();
runApp(MyApp());
}
Show Notification
EasyLocalNotify.show('Title', 'This is a notification body');
Schedule Notification
EasyLocalNotify.schedule(
'Reminder',
'This will appear after 5 seconds',
DateTime.now().add(Duration(seconds: 5)),
);
Notes
- On Web, scheduled notifications are shown immediately.
- On Android/iOS, the notifications can be scheduled to appear later.
- The package handles permission requests automatically; no extra code is needed.
Example
See the example/
folder for a complete working Flutter project demonstrating usage.