diff --git a/flutter_local_notifications/example/lib/main.dart b/flutter_local_notifications/example/lib/main.dart index 011653a2b..55243f1f1 100644 --- a/flutter_local_notifications/example/lib/main.dart +++ b/flutter_local_notifications/example/lib/main.dart @@ -1079,7 +1079,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1172,7 +1175,10 @@ class _HomePageState extends State { windows: windowsNotificationsDetails, ); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item z'); } @@ -1224,8 +1230,11 @@ class _HomePageState extends State { windows: windowsNotificationDetails, ); - await flutterLocalNotificationsPlugin.show(id++, 'Text Input Notification', - 'Expand to see input action', notificationDetails, + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'Text Input Notification', + body: 'Expand to see input action', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1244,7 +1253,10 @@ class _HomePageState extends State { linux: linuxNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item z'); } @@ -1303,7 +1315,10 @@ class _HomePageState extends State { windows: windowsNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1348,11 +1363,12 @@ class _HomePageState extends State { TextButton( onPressed: () async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'scheduled title', - 'scheduled body', - tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), - const NotificationDetails( + id: 0, + title: 'scheduled title', + body: 'scheduled body', + scheduledDate: tz.TZDateTime.now(tz.local) + .add(const Duration(seconds: 5)), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails( 'full screen channel id', 'full screen channel name', channelDescription: 'full screen channel description', @@ -1381,7 +1397,9 @@ class _HomePageState extends State { android: androidNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', null, notificationDetails, + id: id++, + body: 'plain title', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1395,8 +1413,11 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( android: androidNotificationDetails, ); - await flutterLocalNotificationsPlugin - .show(id++, null, 'plain body', notificationDetails, payload: 'item x'); + await flutterLocalNotificationsPlugin.show( + id: id++, + body: 'plain body', + notificationDetails: notificationDetails, + payload: 'item x'); } Future _cancelNotification() async { @@ -1438,10 +1459,10 @@ class _HomePageState extends State { windows: windowsNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, - 'custom sound notification title', - 'custom sound notification body', - notificationDetails, + id: id++, + title: 'custom sound notification title', + body: 'custom sound notification body', + notificationDetails: notificationDetails, ); } @@ -1468,19 +1489,22 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'title of notification with custom vibration pattern, LED and icon', - 'body of notification with custom vibration pattern, LED and icon', - notificationDetails); + id: id++, + title: + 'title of notification with custom vibration pattern, LED and icon', + body: + 'body of notification with custom vibration pattern, LED and icon', + notificationDetails: notificationDetails); } Future _zonedScheduleNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'scheduled title', - 'scheduled body', - tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), - const NotificationDetails( + id: 0, + title: 'scheduled title', + body: 'scheduled body', + scheduledDate: + tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails( 'your channel id', 'your channel name', channelDescription: 'your channel description')), @@ -1489,11 +1513,12 @@ class _HomePageState extends State { Future _zonedScheduleAlarmClockNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 123, - 'scheduled alarm clock title', - 'scheduled alarm clock body', - tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), - const NotificationDetails( + id: 123, + title: 'scheduled alarm clock title', + body: 'scheduled alarm clock body', + scheduledDate: + tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails( 'alarm_clock_channel', 'Alarm Clock Channel', channelDescription: 'Alarm Clock Notification')), @@ -1518,7 +1543,10 @@ class _HomePageState extends State { iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'silent title', 'silent body', notificationDetails); + id: id++, + title: 'silent title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _showNotificationSilently() async { @@ -1541,7 +1569,10 @@ class _HomePageState extends State { iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'silent title', 'silent body', notificationDetails); + id: id++, + title: 'silent title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _showSoundUriNotification() async { @@ -1559,7 +1590,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'uri sound title', 'uri sound body', notificationDetails); + id: id++, + title: 'uri sound title', + body: 'uri sound body', + notificationDetails: notificationDetails); } Future _showTimeoutNotification() async { @@ -1570,8 +1604,11 @@ class _HomePageState extends State { styleInformation: DefaultStyleInformation(true, true)); const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); - await flutterLocalNotificationsPlugin.show(id++, 'timeout notification', - 'Times out after 3 seconds', notificationDetails); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'timeout notification', + body: 'Times out after 3 seconds', + notificationDetails: notificationDetails); } Future _showInsistentNotification() async { @@ -1587,7 +1624,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'insistent title', 'insistent body', notificationDetails, + id: id++, + title: 'insistent title', + body: 'insistent body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1620,7 +1660,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'big text title', 'silent body', notificationDetails); + id: id++, + title: 'big text title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _base64encodedImage(String url) async { @@ -1652,7 +1695,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'big text title', 'silent body', notificationDetails); + id: id++, + title: 'big text title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _getByteArrayFromUrl(String url) async { @@ -1681,7 +1727,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'big text title', 'silent body', notificationDetails); + id: id++, + title: 'big text title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _showBigPictureNotificationHiddenLargeIcon() async { @@ -1705,7 +1754,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'big text title', 'silent body', notificationDetails); + id: id++, + title: 'big text title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _showNotificationMediaStyle() async { @@ -1722,7 +1774,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'notification title', 'notification body', notificationDetails); + id: id++, + title: 'notification title', + body: 'notification body', + notificationDetails: notificationDetails); } Future _showBigTextNotification() async { @@ -1743,7 +1798,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'big text title', 'silent body', notificationDetails); + id: id++, + title: 'big text title', + body: 'silent body', + notificationDetails: notificationDetails); } Future _showInboxNotification() async { @@ -1762,7 +1820,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'inbox title', 'inbox body', notificationDetails); + id: id++, + title: 'inbox title', + body: 'inbox body', + notificationDetails: notificationDetails); } Future _showMessagingNotification() async { @@ -1829,14 +1890,20 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id, 'message title', 'message body', notificationDetails); + id: id, + title: 'message title', + body: 'message body', + notificationDetails: notificationDetails); // wait 10 seconds and add another message to simulate another response await Future.delayed(const Duration(seconds: 10), () async { messages.add(Message("I'm so sorry!!! But I really like thai food ...", DateTime.now().add(const Duration(minutes: 11)), null)); await flutterLocalNotificationsPlugin.show( - id++, 'message title', 'message body', notificationDetails); + id: id++, + title: 'message title', + body: 'message body', + notificationDetails: notificationDetails); }); } @@ -1854,8 +1921,11 @@ class _HomePageState extends State { groupKey: groupKey); const NotificationDetails firstNotificationPlatformSpecifics = NotificationDetails(android: firstNotificationAndroidSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'Alex Faarborg', - 'You will not believe...', firstNotificationPlatformSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'Alex Faarborg', + body: 'You will not believe...', + notificationDetails: firstNotificationPlatformSpecifics); const AndroidNotificationDetails secondNotificationAndroidSpecifics = AndroidNotificationDetails(groupChannelId, groupChannelName, channelDescription: groupChannelDescription, @@ -1865,10 +1935,10 @@ class _HomePageState extends State { const NotificationDetails secondNotificationPlatformSpecifics = NotificationDetails(android: secondNotificationAndroidSpecifics); await flutterLocalNotificationsPlugin.show( - id++, - 'Jeff Chang', - 'Please join us to celebrate the...', - secondNotificationPlatformSpecifics); + id: id++, + title: 'Jeff Chang', + body: 'Please join us to celebrate the...', + notificationDetails: secondNotificationPlatformSpecifics); // Create the summary notification to support older devices that pre-date /// Android 7.0 (API level 24). @@ -1892,7 +1962,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'Attention', 'Two messages', notificationDetails); + id: id++, + title: 'Attention', + body: 'Two messages', + notificationDetails: notificationDetails); } Future _showNotificationWithTag() async { @@ -1906,7 +1979,9 @@ class _HomePageState extends State { android: androidNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, 'first notification', null, notificationDetails); + id: id++, + title: 'first notification', + notificationDetails: notificationDetails); } Future _checkPendingNotificationRequests() async { @@ -1949,10 +2024,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'ongoing notification title', - 'ongoing notification body', - notificationDetails); + id: id++, + title: 'ongoing notification title', + body: 'ongoing notification body', + notificationDetails: notificationDetails); } Future _showNotificationWithNoBadge() async { @@ -1966,7 +2041,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'no badge title', 'no badge body', notificationDetails, + id: id++, + title: 'no badge title', + body: 'no badge body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -1989,10 +2067,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - progressId, - 'progress notification title', - 'progress notification body', - notificationDetails, + id: progressId, + title: 'progress notification title', + body: 'progress notification body', + notificationDetails: notificationDetails, payload: 'item x'); }); } @@ -2012,10 +2090,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'indeterminate progress notification title', - 'indeterminate progress notification body', - notificationDetails, + id: id++, + title: 'indeterminate progress notification title', + body: 'indeterminate progress notification body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2029,10 +2107,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'updated notification channel', - 'check settings to see updated channel description', - notificationDetails, + id: id++, + title: 'updated notification channel', + body: 'check settings to see updated channel description', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2047,10 +2125,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'public notification title', - 'public notification body', - notificationDetails, + id: id++, + title: 'public notification title', + body: 'public notification body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2062,10 +2140,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'title of notification with a subtitle', - 'body of notification with a subtitle', - notificationDetails, + id: id++, + title: 'title of notification with a subtitle', + body: 'body of notification with a subtitle', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2075,7 +2153,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'icon badge title', 'icon badge body', notificationDetails, + id: id++, + title: 'icon badge title', + body: 'icon badge body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2096,19 +2177,37 @@ class _HomePageState extends State { final NotificationDetails thread2PlatformChannelSpecifics = buildNotificationDetailsForThread('thread2'); - await flutterLocalNotificationsPlugin.show(id++, 'thread 1', - 'first notification', thread1PlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'thread 1', - 'second notification', thread1PlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'thread 1', - 'third notification', thread1PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 1', + body: 'first notification', + notificationDetails: thread1PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 1', + body: 'second notification', + notificationDetails: thread1PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 1', + body: 'third notification', + notificationDetails: thread1PlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'thread 2', - 'first notification', thread2PlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'thread 2', - 'second notification', thread2PlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(id++, 'thread 2', - 'third notification', thread2PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 2', + body: 'first notification', + notificationDetails: thread2PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 2', + body: 'second notification', + notificationDetails: thread2PlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.show( + id: id++, + title: 'thread 2', + body: 'third notification', + notificationDetails: thread2PlatformChannelSpecifics); } Future _showNotificationWithTimeSensitiveInterruptionLevel() async { @@ -2119,10 +2218,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'title of time sensitive notification', - 'body of time sensitive notification', - notificationDetails, + id: id++, + title: 'title of time sensitive notification', + body: 'body of time sensitive notification', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2135,10 +2234,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'title of banner notification', - 'body of banner notification', - notificationDetails, + id: id++, + title: 'title of banner notification', + body: 'body of banner notification', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2151,10 +2250,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'title of notification shown only in notification centre', - 'body of notification shown only in notification centre', - notificationDetails, + id: id++, + title: 'title of notification shown only in notification centre', + body: 'body of notification shown only in notification centre', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2168,7 +2267,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2185,7 +2287,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2203,7 +2308,10 @@ class _HomePageState extends State { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2222,7 +2330,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, 'plain title', 'plain body', notificationDetails, + id: id++, + title: 'plain title', + body: 'plain body', + notificationDetails: notificationDetails, payload: 'item x'); } @@ -2243,10 +2354,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with attachment title', - 'notification with attachment body', - notificationDetails); + id: id++, + title: 'notification with attachment title', + body: 'notification with attachment body', + notificationDetails: notificationDetails); } Future _showNotificationWithClippedThumbnailAttachment() async { @@ -2271,10 +2382,10 @@ class _HomePageState extends State { final NotificationDetails notificationDetails = NotificationDetails( iOS: darwinNotificationDetails, macOS: darwinNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with attachment title', - 'notification with attachment body', - notificationDetails); + id: id++, + title: 'notification with attachment title', + body: 'notification with attachment body', + notificationDetails: notificationDetails); } Future _createNotificationChannelGroup() async { @@ -2462,10 +2573,10 @@ class _HomePageState extends State { NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.show( - id++, - 'I ignored dnd', - 'I completely ignored dnd', - notificationDetails, + id: id++, + title: 'I ignored dnd', + body: 'I completely ignored dnd', + notificationDetails: notificationDetails, ); } @@ -2831,7 +2942,10 @@ class _HomePageState extends State { const NotificationDetails platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( - 0, 'icon badge title', 'icon badge body', platformChannelSpecifics, + id: 0, + title: 'icon badge title', + body: 'icon badge body', + notificationDetails: platformChannelSpecifics, payload: 'item x'); } @@ -2848,10 +2962,10 @@ class _HomePageState extends State { const NotificationDetails platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( - 0, - 'notification sound controlled by alarm volume', - 'alarm notification sound body', - platformChannelSpecifics, + id: 0, + title: 'notification sound controlled by alarm volume', + body: 'alarm notification sound body', + notificationDetails: platformChannelSpecifics, ); } @@ -2868,24 +2982,23 @@ class _HomePageState extends State { macOS: darwinNotificationDetails, ); await flutterLocalNotificationsPlugin.show( - id++, - 'Critical sound notification title', - 'Critical sound notification body', - notificationDetails, + id: id++, + title: 'Critical sound notification title', + body: 'Critical sound notification body', + notificationDetails: notificationDetails, ); } } Future _showLinuxNotificationWithBodyMarkup() async { await flutterLocalNotificationsPlugin.show( - id++, - 'notification with body markup', - 'bold text\n' + id: id++, + title: 'notification with body markup', + body: 'bold text\n' 'italic text\n' 'underline text\n' 'https://example.com\n' 'example.com', - null, ); } @@ -2898,10 +3011,9 @@ Future _showLinuxNotificationWithCategory() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with category', - null, - notificationDetails, + id: id++, + title: 'notification with category', + notificationDetails: notificationDetails, ); } @@ -2930,10 +3042,9 @@ Future _showLinuxNotificationWithByteDataIcon() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with byte data icon', - null, - notificationDetails, + id: id++, + title: 'notification with byte data icon', + notificationDetails: notificationDetails, ); } @@ -2944,10 +3055,9 @@ Future _showLinuxNotificationWithPathIcon(String path) async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - 0, - 'notification with file path icon', - null, - platformChannelSpecifics, + id: 0, + title: 'notification with file path icon', + notificationDetails: platformChannelSpecifics, ); } @@ -2960,10 +3070,9 @@ Future _showLinuxNotificationWithThemeIcon() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with theme icon', - null, - notificationDetails, + id: id++, + title: 'notification with theme icon', + notificationDetails: notificationDetails, ); } @@ -2976,10 +3085,9 @@ Future _showLinuxNotificationWithThemeSound() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with theme sound', - null, - notificationDetails, + id: id++, + title: 'notification with theme sound', + notificationDetails: notificationDetails, ); } @@ -2992,10 +3100,9 @@ Future _showLinuxNotificationWithCriticalUrgency() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with critical urgency', - null, - notificationDetails, + id: id++, + title: 'notification with critical urgency', + notificationDetails: notificationDetails, ); } @@ -3010,10 +3117,9 @@ Future _showLinuxNotificationWithTimeout() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification with timeout', - null, - notificationDetails, + id: id++, + title: 'notification with timeout', + notificationDetails: notificationDetails, ); } @@ -3026,10 +3132,9 @@ Future _showLinuxNotificationSuppressSound() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'suppress notification sound', - null, - notificationDetails, + id: id++, + title: 'suppress notification sound', + notificationDetails: notificationDetails, ); } @@ -3042,10 +3147,9 @@ Future _showLinuxNotificationTransient() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'transient notification', - null, - notificationDetails, + id: id++, + title: 'transient notification', + notificationDetails: notificationDetails, ); } @@ -3058,10 +3162,9 @@ Future _showLinuxNotificationResident() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'resident notification', - null, - notificationDetails, + id: id++, + title: 'resident notification', + notificationDetails: notificationDetails, ); } @@ -3072,10 +3175,9 @@ Future _showLinuxNotificationDifferentLocation() async { linux: linuxPlatformChannelSpecifics, ); await flutterLocalNotificationsPlugin.show( - id++, - 'notification on different screen location', - null, - notificationDetails, + id: id++, + title: 'notification on different screen location', + notificationDetails: notificationDetails, ); } diff --git a/flutter_local_notifications/example/lib/repeating.dart b/flutter_local_notifications/example/lib/repeating.dart index 26ce7d9dc..5cdaae852 100644 --- a/flutter_local_notifications/example/lib/repeating.dart +++ b/flutter_local_notifications/example/lib/repeating.dart @@ -70,11 +70,11 @@ List examples(BuildContext context) => [ /// To test we don't validate past dates when using `matchDateTimeComponents` Future _scheduleDailyTenAMLastYearNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'daily scheduled notification title', - 'daily scheduled notification body', - _nextInstanceOfTenAMLastYear(), - const NotificationDetails( + id: 0, + title: 'daily scheduled notification title', + body: 'daily scheduled notification body', + scheduledDate: _nextInstanceOfTenAMLastYear(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails( 'daily notification channel id', 'daily notification channel name', channelDescription: 'daily notification description'), @@ -85,11 +85,11 @@ Future _scheduleDailyTenAMLastYearNotification() async { Future _scheduleWeeklyTenAMNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'weekly scheduled notification title', - 'weekly scheduled notification body', - _nextInstanceOfTenAM(), - const NotificationDetails( + id: 0, + title: 'weekly scheduled notification title', + body: 'weekly scheduled notification body', + scheduledDate: _nextInstanceOfTenAM(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails('weekly notification channel id', 'weekly notification channel name', channelDescription: 'weekly notificationdescription'), @@ -100,11 +100,11 @@ Future _scheduleWeeklyTenAMNotification() async { Future _scheduleWeeklyMondayTenAMNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'weekly scheduled notification title', - 'weekly scheduled notification body', - _nextInstanceOfMondayTenAM(), - const NotificationDetails( + id: 0, + title: 'weekly scheduled notification title', + body: 'weekly scheduled notification body', + scheduledDate: _nextInstanceOfMondayTenAM(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails('weekly notification channel id', 'weekly notification channel name', channelDescription: 'weekly notificationdescription'), @@ -115,11 +115,11 @@ Future _scheduleWeeklyMondayTenAMNotification() async { Future _scheduleMonthlyMondayTenAMNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'monthly scheduled notification title', - 'monthly scheduled notification body', - _nextInstanceOfMondayTenAM(), - const NotificationDetails( + id: 0, + title: 'monthly scheduled notification title', + body: 'monthly scheduled notification body', + scheduledDate: _nextInstanceOfMondayTenAM(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails('monthly notification channel id', 'monthly notification channel name', channelDescription: 'monthly notificationdescription'), @@ -130,11 +130,11 @@ Future _scheduleMonthlyMondayTenAMNotification() async { Future _scheduleYearlyMondayTenAMNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'yearly scheduled notification title', - 'yearly scheduled notification body', - _nextInstanceOfMondayTenAM(), - const NotificationDetails( + id: 0, + title: 'yearly scheduled notification title', + body: 'yearly scheduled notification body', + scheduledDate: _nextInstanceOfMondayTenAM(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails('yearly notification channel id', 'yearly notification channel name', channelDescription: 'yearly notification description'), @@ -151,11 +151,11 @@ Future _repeatNotification() async { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.periodicallyShow( - id++, - 'repeating title', - 'repeating body', - RepeatInterval.everyMinute, - notificationDetails, + id: id++, + title: 'repeating title', + body: 'repeating body', + repeatInterval: RepeatInterval.everyMinute, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, ); } @@ -168,22 +168,22 @@ Future _repeatPeriodicallyWithDurationNotification() async { const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails); await flutterLocalNotificationsPlugin.periodicallyShowWithDuration( - id++, - 'repeating period title', - 'repeating period body', - const Duration(minutes: 5), - notificationDetails, + id: id++, + title: 'repeating period title', + body: 'repeating period body', + repeatDurationInterval: const Duration(minutes: 5), + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, ); } Future _scheduleDailyTenAMNotification() async { await flutterLocalNotificationsPlugin.zonedSchedule( - 0, - 'daily scheduled notification title', - 'daily scheduled notification body', - _nextInstanceOfTenAM(), - const NotificationDetails( + id: 0, + title: 'daily scheduled notification title', + body: 'daily scheduled notification body', + scheduledDate: _nextInstanceOfTenAM(), + notificationDetails: const NotificationDetails( android: AndroidNotificationDetails( 'daily notification channel id', 'daily notification channel name', channelDescription: 'daily notification description'), diff --git a/flutter_local_notifications/example/lib/windows.dart b/flutter_local_notifications/example/lib/windows.dart index 025c8b186..d486665d2 100644 --- a/flutter_local_notifications/example/lib/windows.dart +++ b/flutter_local_notifications/example/lib/windows.dart @@ -145,19 +145,19 @@ List examples() => [ Future _showWindowsNotificationWithDuration() async { await flutterLocalNotificationsPlugin.show( - id++, - 'This is a short notification', - 'This will last about 7 seconds', - const NotificationDetails( + id: id++, + title: 'This is a short notification', + body: 'This will last about 7 seconds', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( duration: WindowsNotificationDuration.short), ), ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is a long notification', - 'This will last about 25 seconds', - const NotificationDetails( + id: id++, + title: 'This is a long notification', + body: 'This will last about 25 seconds', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( duration: WindowsNotificationDuration.long), ), @@ -166,10 +166,9 @@ Future _showWindowsNotificationWithDuration() async { Future _showWindowsNotificationWithScenarios() async { await flutterLocalNotificationsPlugin.show( - id++, - 'This is an alarm', - null, - const NotificationDetails( + id: id++, + title: 'This is an alarm', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( scenario: WindowsNotificationScenario.alarm, actions: [ @@ -179,10 +178,9 @@ Future _showWindowsNotificationWithScenarios() async { ), ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is an incoming call', - null, - const NotificationDetails( + id: id++, + title: 'This is an incoming call', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( scenario: WindowsNotificationScenario.incomingCall, actions: [ @@ -192,10 +190,9 @@ Future _showWindowsNotificationWithScenarios() async { ), ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is a reminder', - null, - const NotificationDetails( + id: id++, + title: 'This is a reminder', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( scenario: WindowsNotificationScenario.reminder, actions: [ @@ -204,10 +201,9 @@ Future _showWindowsNotificationWithScenarios() async { ), ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is an urgent notification', - null, - const NotificationDetails( + id: id++, + title: 'This is an urgent notification', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( scenario: WindowsNotificationScenario.urgent, actions: [ @@ -219,10 +215,10 @@ Future _showWindowsNotificationWithScenarios() async { Future _showWindowsNotificationWithDetails() => flutterLocalNotificationsPlugin.show( - id++, - 'This one has more details', - 'And a different timestamp!', - NotificationDetails( + id: id++, + title: 'This one has more details', + body: 'And a different timestamp!', + notificationDetails: NotificationDetails( windows: WindowsNotificationDetails( subtitle: 'This is the subtitle', timestamp: @@ -233,10 +229,11 @@ Future _showWindowsNotificationWithDetails() => Future _showWindowsNotificationWithImages() => flutterLocalNotificationsPlugin.show( - id++, - 'This notification has an image', - 'You can show images from assets or the network. See the columns example as well.', - NotificationDetails( + id: id++, + title: 'This notification has an image', + body: + 'You can show images from assets or the network. See the columns example as well.', + notificationDetails: NotificationDetails( windows: WindowsNotificationDetails( images: [ WindowsImage( @@ -250,10 +247,10 @@ Future _showWindowsNotificationWithImages() => Future _showWindowsNotificationWithGroups() => flutterLocalNotificationsPlugin.show( - id++, - 'This notification has many groups', - 'Each group stays together. Web images only load in MSIX builds', - NotificationDetails( + id: id++, + title: 'This notification has many groups', + body: 'Each group stays together. Web images only load in MSIX builds', + notificationDetails: NotificationDetails( windows: WindowsNotificationDetails( subtitle: 'Caption text is fainter', rows: [ @@ -294,10 +291,10 @@ Future _showWindowsNotificationWithProgress() async { flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation< FlutterLocalNotificationsWindows>(); await flutterLocalNotificationsPlugin.show( - notificationId, - 'This notification has progress bars', - 'You can have precise or indeterminate', - NotificationDetails( + id: notificationId, + title: 'This notification has progress bars', + body: 'You can have precise or indeterminate', + notificationDetails: NotificationDetails( windows: WindowsNotificationDetails( progressBars: [ WindowsProgressBar( @@ -350,10 +347,10 @@ Future _showWindowsNotificationWithDynamic() async { flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation< FlutterLocalNotificationsWindows>(); await flutterLocalNotificationsPlugin.show( - notificationId, - 'Dynamic content', - 'This notification will be updated from Dart code', - const NotificationDetails( + id: notificationId, + title: 'Dynamic content', + body: 'This notification will be updated from Dart code', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( subtitle: '{stopwatch}', ), @@ -376,10 +373,10 @@ Future _showWindowsNotificationWithDynamic() async { Future _showWindowsNotificationWithActivation() => flutterLocalNotificationsPlugin.show( - id++, - 'These buttons do different things', - 'Click on each one!', - const NotificationDetails( + id: id++, + title: 'These buttons do different things', + body: 'Click on each one!', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( actions: [ WindowsAction( @@ -400,10 +397,10 @@ Future _showWindowsNotificationWithActivation() => Future _showWindowsNotificationWithButtonStyle() => flutterLocalNotificationsPlugin.show( - id++, - 'Incoming call', - 'Your best friend', - const NotificationDetails( + id: id++, + title: 'Incoming call', + body: 'Your best friend', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails( actions: [ WindowsAction( @@ -428,18 +425,16 @@ Future _showWindowsNotificationWithHeader() async { arguments: 'header-clicked', ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is the first notification', - null, - const NotificationDetails( + id: id++, + title: 'This is the first notification', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails(header: header), ), ); await flutterLocalNotificationsPlugin.show( - id++, - 'This is the second notification', - null, - const NotificationDetails( + id: id++, + title: 'This is the second notification', + notificationDetails: const NotificationDetails( windows: WindowsNotificationDetails(header: header), ), ); diff --git a/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart b/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart index 4a9650131..a730edf35 100644 --- a/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart +++ b/flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart @@ -230,11 +230,11 @@ class FlutterLocalNotificationsPlugin { /// Show a notification with an optional payload that will be passed back to /// the app when a notification is tapped. - Future show( - int id, + Future show({ + required int id, String? title, String? body, - NotificationDetails? notificationDetails, { + NotificationDetails? notificationDetails, String? payload, }) async { if (kIsWeb) { @@ -342,13 +342,13 @@ class FlutterLocalNotificationsPlugin { /// /// On Windows, this will only set a notification on the [scheduledDate], and /// not repeat, regardless of the value for [matchDateTimeComponents]. - Future zonedSchedule( - int id, + Future zonedSchedule({ + required int id, + required TZDateTime scheduledDate, + required NotificationDetails notificationDetails, + required AndroidScheduleMode androidScheduleMode, String? title, String? body, - TZDateTime scheduledDate, - NotificationDetails notificationDetails, { - required AndroidScheduleMode androidScheduleMode, String? payload, DateTimeComponents? matchDateTimeComponents, }) async { @@ -402,13 +402,13 @@ class FlutterLocalNotificationsPlugin { /// On Android, this will also require additional setup for the app, /// especially in the app's `AndroidManifest.xml` file. Please see check the /// readme for further details. - Future periodicallyShow( - int id, + Future periodicallyShow({ + required int id, + required RepeatInterval repeatInterval, + required NotificationDetails notificationDetails, + required AndroidScheduleMode androidScheduleMode, String? title, String? body, - RepeatInterval repeatInterval, - NotificationDetails notificationDetails, { - required AndroidScheduleMode androidScheduleMode, String? payload, }) async { if (kIsWeb) { @@ -449,12 +449,12 @@ class FlutterLocalNotificationsPlugin { /// On Android, this will also require additional setup for the app, /// especially in the app's `AndroidManifest.xml` file. Please see check the /// readme for further details. - Future periodicallyShowWithDuration( - int id, + Future periodicallyShowWithDuration({ + required int id, + required Duration repeatDurationInterval, + required NotificationDetails notificationDetails, String? title, String? body, - Duration repeatDurationInterval, - NotificationDetails notificationDetails, { AndroidScheduleMode androidScheduleMode = AndroidScheduleMode.exact, String? payload, }) async { diff --git a/flutter_local_notifications/test/android_flutter_local_notifications_test.dart b/flutter_local_notifications/test/android_flutter_local_notifications_test.dart index f45e8f90e..7e9659112 100644 --- a/flutter_local_notifications/test/android_flutter_local_notifications_test.dart +++ b/flutter_local_notifications/test/android_flutter_local_notifications_test.dart @@ -66,7 +66,7 @@ void main() { InitializationSettings(android: androidInitializationSettings); await flutterLocalNotificationsPlugin.initialize(initializationSettings); await flutterLocalNotificationsPlugin.show( - 1, 'notification title', 'notification body', null); + id: 1, title: 'notification title', body: 'notification body'); expect( log.last, isMethodCall('show', arguments: { @@ -112,11 +112,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails), - ); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall( @@ -242,10 +242,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -327,10 +328,11 @@ void main() { additionalFlags: Int32List.fromList([4, 32])); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -413,10 +415,11 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription', when: timestamp); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -500,10 +503,11 @@ void main() { when: timestamp, usesChronometer: true); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -589,10 +593,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -679,10 +684,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -769,10 +775,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -858,10 +865,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -949,10 +957,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1055,10 +1064,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1155,10 +1165,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1261,10 +1272,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1359,10 +1371,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1461,10 +1474,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1554,10 +1568,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1644,10 +1659,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - const NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + const NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1741,10 +1757,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1867,10 +1884,11 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - NotificationDetails(android: androidNotificationDetails)); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: + NotificationDetails(android: androidNotificationDetails)); expect( log.last, isMethodCall('show', arguments: { @@ -1975,11 +1993,12 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription'); await flutterLocalNotificationsPlugin.periodicallyShow( - 1, - 'notification title', - 'notification body', - repeatInterval, - const NotificationDetails(android: androidNotificationDetails), + id: 1, + title: 'notification title', + body: 'notification body', + repeatInterval: repeatInterval, + notificationDetails: const NotificationDetails( + android: androidNotificationDetails), androidScheduleMode: AndroidScheduleMode.exact, ); @@ -2077,11 +2096,11 @@ void main() { expect( () async => await flutterLocalNotificationsPlugin .periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - thirtySeconds, - const NotificationDetails( + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: thirtySeconds, + notificationDetails: const NotificationDetails( android: androidNotificationDetails), ), throwsA(isA())); @@ -2109,11 +2128,12 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription'); await flutterLocalNotificationsPlugin.periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - repeatDurationInterval, - const NotificationDetails(android: androidNotificationDetails), + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: repeatDurationInterval, + notificationDetails: const NotificationDetails( + android: androidNotificationDetails), ); expect( @@ -2208,11 +2228,12 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription'); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - const NotificationDetails(android: androidNotificationDetails), + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: + const NotificationDetails(android: androidNotificationDetails), androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle); expect( log.last, @@ -2302,11 +2323,12 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription'); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - const NotificationDetails(android: androidNotificationDetails), + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: + const NotificationDetails(android: androidNotificationDetails), androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.time); expect( @@ -2398,11 +2420,12 @@ void main() { AndroidNotificationDetails('channelId', 'channelName', channelDescription: 'channelDescription'); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - const NotificationDetails(android: androidNotificationDetails), + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: + const NotificationDetails(android: androidNotificationDetails), androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.dayOfWeekAndTime); expect( diff --git a/flutter_local_notifications/test/ios_flutter_local_notifications_test.dart b/flutter_local_notifications/test/ios_flutter_local_notifications_test.dart index f6e66db05..45672f311 100644 --- a/flutter_local_notifications/test/ios_flutter_local_notifications_test.dart +++ b/flutter_local_notifications/test/ios_flutter_local_notifications_test.dart @@ -207,7 +207,7 @@ void main() { InitializationSettings(iOS: iosInitializationSettings); await flutterLocalNotificationsPlugin.initialize(initializationSettings); await flutterLocalNotificationsPlugin.show( - 1, 'notification title', 'notification body', null); + id: 1, title: 'notification title', body: 'notification body'); expect( log.last, isMethodCall('show', arguments: { @@ -245,7 +245,10 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, 'notification title', 'notification body', notificationDetails); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: notificationDetails); expect( log.last, @@ -310,11 +313,11 @@ void main() { ); await flutterLocalNotificationsPlugin.periodicallyShow( - 1, - 'notification title', - 'notification body', - repeatInterval, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatInterval: repeatInterval, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exact); expect( @@ -392,11 +395,11 @@ void main() { expect( () async => await flutterLocalNotificationsPlugin .periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - thirtySeconds, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: thirtySeconds, + notificationDetails: notificationDetails, ), throwsA(isA())); }); @@ -437,11 +440,11 @@ void main() { ); await flutterLocalNotificationsPlugin.periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - repeatDurationInterval, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: repeatDurationInterval, + notificationDetails: notificationDetails, ); expect( @@ -513,11 +516,11 @@ void main() { ])); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle); expect( @@ -581,11 +584,11 @@ void main() { ])); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.time); @@ -651,11 +654,11 @@ void main() { ])); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.dayOfWeekAndTime); diff --git a/flutter_local_notifications/test/macos_flutter_local_notifications_test.dart b/flutter_local_notifications/test/macos_flutter_local_notifications_test.dart index 44359dc66..13209574f 100644 --- a/flutter_local_notifications/test/macos_flutter_local_notifications_test.dart +++ b/flutter_local_notifications/test/macos_flutter_local_notifications_test.dart @@ -102,7 +102,7 @@ void main() { InitializationSettings(macOS: macOSInitializationSettings); await flutterLocalNotificationsPlugin.initialize(initializationSettings); await flutterLocalNotificationsPlugin.show( - 1, 'notification title', 'notification body', null); + id: 1, title: 'notification title', body: 'notification body'); expect( log.last, isMethodCall('show', arguments: { @@ -144,11 +144,10 @@ void main() { ); await flutterLocalNotificationsPlugin.show( - 1, - 'notification title', - 'notification body', - notificationDetails, - ); + id: 1, + title: 'notification title', + body: 'notification body', + notificationDetails: notificationDetails); expect( log.last, @@ -217,11 +216,11 @@ void main() { ); await flutterLocalNotificationsPlugin.periodicallyShow( - 1, - 'notification title', - 'notification body', - repeatInterval, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatInterval: repeatInterval, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exact, ); @@ -296,11 +295,11 @@ void main() { expect( () async => await flutterLocalNotificationsPlugin .periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - thirtySeconds, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: thirtySeconds, + notificationDetails: notificationDetails, ), throwsA(isA())); }); @@ -342,11 +341,11 @@ void main() { ); await flutterLocalNotificationsPlugin.periodicallyShowWithDuration( - 1, - 'notification title', - 'notification body', - repeatDurationInterval, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + repeatDurationInterval: repeatDurationInterval, + notificationDetails: notificationDetails, ); expect( @@ -418,11 +417,11 @@ void main() { ); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle); expect( @@ -488,11 +487,11 @@ void main() { ); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.time, ); @@ -565,11 +564,11 @@ void main() { ); await flutterLocalNotificationsPlugin.zonedSchedule( - 1, - 'notification title', - 'notification body', - scheduledDate, - notificationDetails, + id: 1, + title: 'notification title', + body: 'notification body', + scheduledDate: scheduledDate, + notificationDetails: notificationDetails, androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, matchDateTimeComponents: DateTimeComponents.dayOfWeekAndTime, );