I want to trigger a local Notification daily on a specific time(Chosen by user). Similar to alarm type. With the help of date picker. User must select the days and time, it should push a local Notification on that time daily.
Asked
Active
Viewed 1,143 times
1 Answers
2
Assuming you have already preset flutter_local_notification
you can go ahead and do it as follows
DateTime scheduledTime
handles date time allocation
import 'package:flutter_local_notifications/flutter_local_notifications.dart'as notifs;
Future<void> scheduleNotification(
{notifs.FlutterLocalNotificationsPlugin notifsPlugin,
String id,
String title,
String body,
DateTime scheduledTime}) async {
var androidSpecifics = notifs.AndroidNotificationDetails(
id, // This specifies the ID of the Notification
'Scheduled notification', // This specifies the name of the notification channel
'A scheduled notification', //This specifies the description of the channel
icon: 'icon',
);
var iOSSpecifics = notifs.IOSNotificationDetails();
var platformChannelSpecifics = notifs.NotificationDetails(
androidSpecifics, iOSSpecifics);
await notifsPlugin.schedule(0, title, "Scheduled notification",
scheduledTime, platformChannelSpecifics); // This literally schedules the notification
}
How will user choose the date(for how many days local notification should be triggered daily on a specific time
you can use datetime picker to select date if its a one occurrence notification
if it has to occur on different days same time , you can use a workmanager and run every 24 hrs and end the services after no of frequencies are over
check this blog post

Ravindra S. Patil
- 11,757
- 3
- 13
- 40

griffins
- 7,079
- 4
- 29
- 54
-
you can read more here https://medium.com/@fuzzymemory/adding-scheduled-notifications-in-your-flutter-application-19be1f82ade8 – griffins Aug 08 '21 at 14:45
-
How will user choose the date(for how many days local notification should be triggered daily on a specific time)? I don't want it hardcoded. User must select the days with datepicker or something. – Hadi Khan Aug 08 '21 at 17:35