Skip to content

Commit af67dec

Browse files
authored
[flutter_local_notifications] lower Flutter SDK to hotfix 5 due to pub issues and optimise usage of Gson (#464)
* reuse gson instance * change flutter sdk requirement * use ArgumentError.checkNotNull and mention removal of upper SDK constraint in changelog
1 parent 09e587f commit af67dec

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

flutter_local_notifications/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# [1.1.5]
2+
* [Android] minor optimisation on scheduling related code so that `Gson` instance is reused instead of being rebuilt each time
3+
* Changed plugin to require 1.12.3+hotfix.5 or greater since pub has issues resolving 1.12.3+hotfix.6
4+
* Updated changelog entry for version 1.1.4 to mention removal of upper bound constraint on Flutter SDK requirement
5+
16
# [1.1.4]
27
* Support v2 Android embedding. Note that there is currently a [known issue](https://github.com/flutter/flutter/issues/49365) in the Flutter SDK that will cause `onSelectNotification` to fire twice on Android. The fix is in the master channel but hasn't rolled out to other channels. Subscribe to the issue for updates.
3-
* Require Flutter SDK 1.12.3+hotfix.6 or greater
8+
* Require Flutter SDK 1.12.3+hotfix.6 or greater. Maximum SDK restraint has also been removed
49

510
# [1.1.3]
611
* Expose `NotificationAppLaunchDetails` via main plugin

flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public class FlutterLocalNotificationsPlugin implements MethodCallHandler, Plugi
9898
private MethodChannel channel;
9999
private Context applicationContext;
100100
private Activity mainActivity;
101+
static Gson gson;
101102

102103

103104
public static void registerWith(Registrar registrar) {
@@ -124,7 +125,6 @@ public void onAttachedToEngine(FlutterPluginBinding binding) {
124125

125126
@Override
126127
public void onDetachedFromEngine(FlutterPluginBinding binding) {
127-
128128
}
129129

130130
@Override
@@ -215,16 +215,19 @@ private static void setSmallIcon(Context context, NotificationDetails notificati
215215

216216
@NonNull
217217
static Gson buildGson() {
218-
RuntimeTypeAdapterFactory<StyleInformation> styleInformationAdapter =
219-
RuntimeTypeAdapterFactory
220-
.of(StyleInformation.class)
221-
.registerSubtype(DefaultStyleInformation.class)
222-
.registerSubtype(BigTextStyleInformation.class)
223-
.registerSubtype(BigPictureStyleInformation.class)
224-
.registerSubtype(InboxStyleInformation.class)
225-
.registerSubtype(MessagingStyleInformation.class);
226-
GsonBuilder builder = new GsonBuilder().registerTypeAdapterFactory(styleInformationAdapter);
227-
return builder.create();
218+
if(gson == null) {
219+
RuntimeTypeAdapterFactory<StyleInformation> styleInformationAdapter =
220+
RuntimeTypeAdapterFactory
221+
.of(StyleInformation.class)
222+
.registerSubtype(DefaultStyleInformation.class)
223+
.registerSubtype(BigTextStyleInformation.class)
224+
.registerSubtype(BigPictureStyleInformation.class)
225+
.registerSubtype(InboxStyleInformation.class)
226+
.registerSubtype(MessagingStyleInformation.class);
227+
GsonBuilder builder = new GsonBuilder().registerTypeAdapterFactory(styleInformationAdapter);
228+
gson = builder.create();
229+
}
230+
return gson;
228231
}
229232

230233
private static ArrayList<NotificationDetails> loadScheduledNotifications(Context context) {

flutter_local_notifications/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ flutter:
2525

2626
environment:
2727
sdk: ">=2.0.0-dev.28.0 <3.0.0"
28-
flutter: ">=1.12.13+hotfix.6"
28+
flutter: ">=1.12.13+hotfix.5"
2929

flutter_local_notifications/lib/src/helpers.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/// Helper method for validating notification IDs.
22
/// Ensures IDs are valid 32-bit integers.
33
void validateId(int id) {
4-
if (id == null) {
5-
throw ArgumentError.notNull('id');
6-
}
7-
4+
ArgumentError.checkNotNull(id, 'id');
85
if (id > 0x7FFFFFFF || id < -0x80000000) {
96
throw ArgumentError.value(id, 'id',
107
'must fit within the size of a 32-bit integer i.e. in the range [-2^31, 2^31 - 1]');

flutter_local_notifications/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_local_notifications
22
description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.
3-
version: 1.1.4
3+
version: 1.1.5
44
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
55

66
dependencies:
@@ -31,4 +31,4 @@ flutter:
3131

3232
environment:
3333
sdk: ">=2.0.0-dev.28.0 <3.0.0"
34-
flutter: ">=1.12.13+hotfix.6"
34+
flutter: ">=1.12.13+hotfix.5"

0 commit comments

Comments
 (0)