From 1977da72a6a0b7b52d646b4f7c9ca809a4a97607 Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Tue, 3 May 2022 19:52:46 +1000 Subject: [PATCH] clean up for 9.5.0 release --- flutter_local_notifications/CHANGELOG.md | 7 +++- .../example/lib/main.dart | 27 +++++++------- .../platform_flutter_local_notifications.dart | 35 ++++++++++--------- flutter_local_notifications/pubspec.yaml | 2 +- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index 5eb1b340f..fcdba090a 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,10 +1,15 @@ +# [9.5.0] + +* [Android] added `getActiveNotificationMessagingStyle()` method to the `AndroidFlutterLocalNotificationsPlugin` class. This allows for getting the messaging style information of an active notification e.g. to append a message to an existing notification. Thanks to the PR from [Simon Ser](https://github.com/emersion) +* Updated readme to fix an issue where clicking on the Android setup and iOS setup sections from table of contents wouldn't go the appropriate section. Thanks to the PR from [HendrikF](https://github.com/HendrikF) + # [9.4.1] * Calling `initialize()` on a platform with passing the appropriate initialisation settings for it will now throw an `ArgumentError`. Whilst this may be technically a breaking change, it's been done as a minor change as the call was already throwing an unhandled exception in these scenarios. This change is to help provide more information on why it fails. Documentation has also been updated to provide more on information on this as the intialisation settings for each platform are nullable so developers aren't forced to provide settings for platforms they don't target. Thanks to the PR from [Zlati Pehlivanov](https://github.com/talamaska) * Updated docs to fix typos, adjust heading levels and use the term ["daylight saving time"](https://en.wikipedia.org/wiki/Daylight_saving_time) instead of "daylight savings". Thanks to the PR from [Ross Llewallyn](https://github.com/EnduringBeta) # [9.4.0] -* [Android] Added `tag` to `ActiveNotification` that would allow for finding the notification's taf. Thanks to the PR from [Simon Ser](https://github.com/emersion) +* [Android] Added `tag` to `ActiveNotification` that would allow for finding the notification's tag. Thanks to the PR from [Simon Ser](https://github.com/emersion) # [9.3.3] * [macOS] Fixed issue [1507](https://github.com/MaikuB/flutter_local_notifications/issues/1507) where calling the `requestPermissions()` method of the `MacOSFlutterLocalNotificationsPlugin` class led to a crash. This will be coalesced to assume that the `boolean` parameters around the requested permissions default to `false` to be consistent with the iOS implementation. Note that in 10.0.0 the method will have a breaking change so that these parameters are non-nullable diff --git a/flutter_local_notifications/example/lib/main.dart b/flutter_local_notifications/example/lib/main.dart index 24b90c2a1..756941128 100644 --- a/flutter_local_notifications/example/lib/main.dart +++ b/flutter_local_notifications/example/lib/main.dart @@ -2027,7 +2027,8 @@ class _HomePageState extends State { TextButton( child: const Text('Get messaging style'), onPressed: () { - _getActiveNotificationMessagingStyle(activeNotification.id, activeNotification.tag); + _getActiveNotificationMessagingStyle( + activeNotification.id, activeNotification.tag); }, ), const Divider(color: Colors.black), @@ -2054,28 +2055,24 @@ class _HomePageState extends State { if (messagingStyle == null) { dialogContent = const Text('No messaging style'); } else { - dialogContent = SingleChildScrollView(child: Column( + dialogContent = SingleChildScrollView( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Text( - 'person: ${_formatPerson(messagingStyle.person)}\n' - 'conversationTitle: ${messagingStyle.conversationTitle}\n' - 'groupConversation: ${messagingStyle.groupConversation}' - ), + Text('person: ${_formatPerson(messagingStyle.person)}\n' + 'conversationTitle: ${messagingStyle.conversationTitle}\n' + 'groupConversation: ${messagingStyle.groupConversation}'), const Divider(color: Colors.black), - if (messagingStyle.messages == null) - const Text('No messages'), + if (messagingStyle.messages == null) const Text('No messages'), if (messagingStyle.messages != null) for (final msg in messagingStyle.messages!) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'text: ${msg.text}\n' - 'timestamp: ${msg.timestamp}\n' - 'person: ${_formatPerson(msg.person)}' - ), + Text('text: ${msg.text}\n' + 'timestamp: ${msg.timestamp}\n' + 'person: ${_formatPerson(msg.person)}'), const Divider(color: Colors.black), ], ), @@ -2112,7 +2109,7 @@ class _HomePageState extends State { return 'null'; } - List attrs = []; + final List attrs = []; if (person.name != null) { attrs.add('name: "${person.name}"'); } diff --git a/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart b/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart index 11ad313d3..f2e0719e0 100644 --- a/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart +++ b/flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:clock/clock.dart'; - import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_local_notifications_platform_interface/flutter_local_notifications_platform_interface.dart'; @@ -10,8 +9,8 @@ import 'package:timezone/timezone.dart'; import 'helpers.dart'; import 'platform_specifics/android/active_notification.dart'; import 'platform_specifics/android/enums.dart'; -import 'platform_specifics/android/initialization_settings.dart'; import 'platform_specifics/android/icon.dart'; +import 'platform_specifics/android/initialization_settings.dart'; import 'platform_specifics/android/message.dart'; import 'platform_specifics/android/method_channel_mappers.dart'; import 'platform_specifics/android/notification_channel.dart'; @@ -20,7 +19,6 @@ import 'platform_specifics/android/notification_details.dart'; import 'platform_specifics/android/notification_sound.dart'; import 'platform_specifics/android/person.dart'; import 'platform_specifics/android/styles/messaging_style_information.dart'; -import 'platform_specifics/android/styles/style_information.dart'; import 'platform_specifics/ios/enums.dart'; import 'platform_specifics/ios/initialization_settings.dart'; import 'platform_specifics/ios/method_channel_mappers.dart'; @@ -422,12 +420,15 @@ class AndroidFlutterLocalNotificationsPlugin /// /// Only [DrawableResourceAndroidIcon] and [ContentUriAndroidIcon] are /// supported for [AndroidIcon] fields. - Future getActiveNotificationMessagingStyle(int id, { String? tag }) async { - final Map? m = - await _channel.invokeMethod('getActiveNotificationMessagingStyle', { - 'id': id, - 'tag': tag, - }); + Future getActiveNotificationMessagingStyle( + int id, { + String? tag, + }) async { + final Map? m = await _channel + .invokeMethod('getActiveNotificationMessagingStyle', { + 'id': id, + 'tag': tag, + }); if (m == null) { return null; } @@ -436,7 +437,9 @@ class AndroidFlutterLocalNotificationsPlugin _personFromMap(m['person'])!, conversationTitle: m['conversationTitle'], groupConversation: m['groupConversation'], - messages: m['messages']?.map((m) => _messageFromMap(m))?.toList(), + messages: + // ignore: always_specify_types + m['messages']?.map((m) => _messageFromMap(m))?.toList(), ); } @@ -454,13 +457,11 @@ class AndroidFlutterLocalNotificationsPlugin ); } - Message _messageFromMap(Map m) { - return Message( - m['text'], - DateTime.fromMillisecondsSinceEpoch(m['timestamp']), - _personFromMap(m['person']), - ); - } + Message _messageFromMap(Map m) => Message( + m['text'], + DateTime.fromMillisecondsSinceEpoch(m['timestamp']), + _personFromMap(m['person']), + ); AndroidIcon? _iconFromMap(Map? m) { if (m == null) { diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index 784d47051..c877de1bf 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_local_notifications description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 9.4.1 +version: 9.5.0 homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications dependencies: