From 82335d1025ce12da2d72872e34ab57c02391ab26 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Tue, 1 Dec 2020 17:19:03 +0100 Subject: [PATCH] testing repeating notification --- lib/pages/NotificationsPage.dart | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/pages/NotificationsPage.dart b/lib/pages/NotificationsPage.dart index 2bfceb2..e5b8b51 100644 --- a/lib/pages/NotificationsPage.dart +++ b/lib/pages/NotificationsPage.dart @@ -38,6 +38,12 @@ class _NotificationPageState extends State { textColor: Colors.white, onPressed: _scheduleNotify ), + FlatButton( + child: Text("Repeat!"), + color: Colors.blue, + textColor: Colors.white, + onPressed: _repeatNotification + ), FlatButton( child: Text("Waiting?"), color: Colors.blue, @@ -107,6 +113,20 @@ class _NotificationPageState extends State { ); } + Future _repeatNotification() async { + const AndroidNotificationDetails androidPlatformChannelSpecifics = + AndroidNotificationDetails( + 'id', + 'name', + 'desc' + ); + const NotificationDetails platformChannelSpecifics = + NotificationDetails(android: androidPlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.periodicallyShow(0, 'repeating title', + 'repeating body', RepeatInterval.hourly, platformChannelSpecifics, + androidAllowWhileIdle: true); + } + Future _cancelAllNotifications() async { await flutterLocalNotificationsPlugin.cancelAll(); }