Scheduling Notifications with Local Notifications in Flutter
FlutterPulseThis article was translated specially for the channel FlutterPulseYou'll find lots of interesting things related to Flutter on this channel. Don't hesitate to subscribe!🚀

Push notifications are great for real-time updates, but what if you need scheduled reminders, periodic alerts, or offline notifications…
Push notifications are great for real-time updates, but what if you need scheduled reminders, periodic alerts, or offline notifications? That's where local notifications come in!
In this guide, you'll learn how to:
✅ Set up local notifications in Flutter
✅ Schedule one-time and recurring notifications
✅ Handle background notifications properly
1️⃣ Why Use Local Notifications?
Unlike push notifications (FCM) that require a server, local notifications work entirely offline on the device.
📌 Use Cases:
✔️ Reminders & Alarms — Schedule a to-do list or medication reminder
✔️ Periodic Updates — Notify users daily or weekly (e.g., fitness tracking)
✔️ Offline Alerts — Notify users without internet access
2️⃣ Setting Up Local Notifications in Flutter
🔹 Step 1: Add Dependencies
In pubspec.yaml:
dependencies:
flutter_local_notifications: ^16.3.0
timezone: ^0.9.2
Run:
flutter pub get
🔹 Step 2: Configure for Android & iOS
Android Setup
Edit AndroidManifest.xml (inside android/app/src/main/AndroidManifest.xml):
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver"
android:exported="false"/>
iOS Setup
For iOS, update ios/Runner/Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
🔹 Step 3: Initialize Local Notifications
Create a new file notification_service.dart:
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
class NotificationService {
static final FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin();
static Future<void> init() async {
// Initialize timezone for scheduling
tz.initializeTimeZones();
const AndroidInitializationSettings androidSettings =
AndroidInitializationSettings('@mipmap/ic_launcher');
const DarwinInitializationSettings iosSettings =
DarwinInitializationSettings();
const InitializationSettings settings = InitializationSettings(
android: androidSettings,
iOS: iosSettings,
);
await _notificationsPlugin.initialize(settings);
}
static Future<void> showNotification(
int id, String title, String body) async {
const AndroidNotificationDetails androidDetails =
AndroidNotificationDetails(
'channel_id',
'channel_name',
importance: Importance.high,
priority: Priority.high,
);
const NotificationDetails details =
NotificationDetails(android: androidDetails);
await _notificationsPlugin.show(id, title, body, details);
}
}
✅ Now, the app can show instant local notifications.
3️⃣ Scheduling Notifications in Flutter
🔹 Scheduling a One-Time Notification
In notification_service.dart, add:
static Future<void> scheduleNotification(
int id, String title, String body, DateTime scheduledTime) async {
await _notificationsPlugin.zonedSchedule(
id,
title,
body,
tz.TZDateTime.from(scheduledTime, tz.local),
const NotificationDetails(
android: AndroidNotificationDetails(
'channel_id',
'Scheduled Notifications',
importance: Importance.high,
priority: Priority.high,
),
),
androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
);
}
✅ Now you can schedule a notification for any future time!
Example:
DateTime scheduledTime = DateTime.now().add(Duration(seconds: 10));
NotificationService.scheduleNotification(1, "Reminder", "This is a scheduled notification", scheduledTime);
This will trigger a notification 10 seconds later.
🔹 Scheduling Repeating Notifications
To send daily, weekly, or custom recurring notifications, modify the function:
static Future<void> scheduleRepeatingNotification(
int id, String title, String body, Duration interval) async {
await _notificationsPlugin.periodicallyShow(
id,
title,
body,
RepeatInterval.everyMinute, // Can be daily, weekly, etc.
const NotificationDetails(
android: AndroidNotificationDetails(
'repeat_channel_id',
'Repeating Notifications',
importance: Importance.high,
priority: Priority.high,
),
),
androidAllowWhileIdle: true,
);
}
Example:
NotificationService.scheduleRepeatingNotification(2, "Daily Reminder", "Check your app!", Duration(days: 1));
✅ This will trigger daily notifications!
🔹 Cancelling Notifications
To cancel a specific notification:
NotificationService.cancelNotification(1);
To cancel all notifications:
NotificationService.cancelAllNotifications();
4️⃣ Implementing Notifications in the UI
Modify main.dart to trigger notifications from the UI:
import 'package:flutter/material.dart';
import 'notification_service.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await NotificationService.init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: NotificationScreen(),
);
}
}
class NotificationScreen extends StatefulWidget {
@override
_NotificationScreenState createState() => _NotificationScreenState();
}
class _NotificationScreenState extends State<NotificationScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Local Notifications")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
NotificationService.showNotification(
1, "Hello!", "This is an instant notification");
},
child: Text("Show Instant Notification"),
),
ElevatedButton(
onPressed: () {
DateTime scheduledTime = DateTime.now().add(Duration(seconds: 10));
NotificationService.scheduleNotification(
2, "Scheduled!", "This will appear after 10 seconds", scheduledTime);
},
child: Text("Schedule Notification"),
),
ElevatedButton(
onPressed: () {
NotificationService.scheduleRepeatingNotification(
3, "Repeating", "This will repeat every minute", Duration(minutes: 1));
},
child: Text("Start Repeating Notification"),
),
ElevatedButton(
onPressed: () {
NotificationService.cancelAllNotifications();
},
child: Text("Cancel All Notifications"),
),
],
),
),
);
}
}
✅ Now you can test instant, scheduled, and repeating notifications! 🎉
🎯 Conclusion
In this guide, we learned how to:
✅ Show instant local notifications
✅ Schedule notifications for future events
✅ Create repeating notifications (daily, weekly, etc.)
✅ Cancel notifications when needed
🚀 What's Next?
🔹 Using WorkManager to schedule background tasks
🔹 Triggering notifications from Firebase Firestore updates
🔹 Customizing notification sounds & styles
Do you want a deep dive into background tasks with WorkManager? Let me know in the comments! 🚀
If you found this story helpful, you can support me at Buy Me a Coffee!