Search code examples
flutternotificationsremindersflutter-notification

Flutter reminder app alarm notification return value


I am writing a reminder application using flutter. I want it to send notifications for the tasks entered at that date and time, even if the application is closed. Its notification should be like the phone's default alarm app. Confirmation snooze buttons and sounds. I'll need what the user did with this notification on another page. I am not using a database. Is there an easy way to do these operations?


Solution

  • You can either use awesome_notifications or flutter_local_notifications

    flutter_local_notifications example

    await flutterLocalNotificationsPlugin.zonedSchedule(
        0,
        'scheduled title',
        'scheduled body',
        tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
        const NotificationDetails(
            android: AndroidNotificationDetails(
                'your channel id', 'your channel name',
                channelDescription: 'your channel description')),
        androidAllowWhileIdle: true,
        uiLocalNotificationDateInterpretation:
            UILocalNotificationDateInterpretation.absoluteTime);
    

    awesome_notifications example

    await AwesomeNotifications().createNotification(
      content: NotificationContent(
          id: id,
          channelKey: 'scheduled',
          title: 'wait 5 seconds to show',
          body: 'now is 5 seconds later',
          wakeUpScreen: true,
          category: NotificationCategory.Alarm,
      ),
      schedule: NotificationInterval(
          interval: 5,
          timeZone: localTimeZone,
          preciseAlarm: true,
          timezone: await AwesomeNotifications().getLocalTimeZoneIdentifier()
      );