1- import 'package:OneSignalFlutter /src/defines.dart' ;
2- import 'package:OneSignalFlutter /src/utils.dart' ;
1+ import 'package:onesignal /src/defines.dart' ;
2+ import 'package:onesignal /src/utils.dart' ;
33import 'package:flutter/foundation.dart' ;
44import 'dart:convert' ;
55
@@ -36,8 +36,8 @@ class OSNotification extends JSONStringRepresentable {
3636 int androidNotificationId;
3737
3838 //converts JSON map to OSNotification instance
39- OSNotification (Map <dynamic , dynamic > json) {
40- this .payload = OSNotificationPayload (json['payload' ] as Map < dynamic , dynamic >);
39+ OSNotification (Map <String , dynamic > json) {
40+ this .payload = OSNotificationPayload (json['payload' ]. cast < String , dynamic >() );
4141 this .shown = json['shown' ] as bool ;
4242 this .appInFocus = json['appInFocus' ] as bool ;
4343 this .silent = json['silent' ] as bool ;
@@ -121,11 +121,11 @@ class OSNotificationPayload extends JSONStringRepresentable {
121121
122122 /// Any additional custom data you want to send along
123123 /// with this notification.
124- Map <dynamic , dynamic > additionalData;
124+ Map <String , dynamic > additionalData;
125125
126126 /// Any attachments (images, sounds, videos) you want
127127 /// to display with this notification.
128- Map <dynamic , dynamic > attachments;
128+ Map <String , dynamic > attachments;
129129
130130 /// Any buttons you want to add to the notification.
131131 /// The notificationOpened handler will provide an
@@ -135,7 +135,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
135135
136136 /// A hashmap object representing the raw key/value
137137 /// properties of the push notification
138- dynamic rawPayload;
138+ Map < String , dynamic > rawPayload;
139139
140140 /// (Android Only)
141141 /// The filename of the image to use as the small
@@ -211,7 +211,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
211211 /// notification (if set)
212212 OSAndroidBackgroundImageLayout backgroundImageLayout;
213213
214- OSNotificationPayload (Map <dynamic , dynamic > json) {
214+ OSNotificationPayload (Map <String , dynamic > json) {
215215 this .notificationId = json['notificationId' ] as String ;
216216
217217 // iOS Specific Parameters
@@ -221,7 +221,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
221221 if (json.containsKey ('badge' )) this .badge = json['badge' ] as int ;
222222 if (json.containsKey ('badgeIncrement' )) this .badgeIncrement = json['badgeIncrement' ] as int ;
223223 if (json.containsKey ('subtitle' )) this .subtitle = json['subtitle' ] as String ;
224- if (json.containsKey ('attachments' )) this .attachments = json['attachments' ] as Map < dynamic , dynamic >;
224+ if (json.containsKey ('attachments' )) this .attachments = json['attachments' ]. cast < String , dynamic >() ;
225225
226226 // Android Specific Parameters
227227 if (json.containsKey ("smallIcon" )) this .smallIcon = json['smallIcon' ] as String ;
@@ -242,10 +242,10 @@ class OSNotificationPayload extends JSONStringRepresentable {
242242 if (json.containsKey ('title' )) this .title = json['title' ] as String ;
243243 if (json.containsKey ('body' )) this .body = json['body' ] as String ;
244244 if (json.containsKey ('launchUrl' )) this .launchUrl = json['launchUrl' ] as String ;
245- if (json.containsKey ('additionalData' )) this .additionalData = json['additionalData' ] as Map < dynamic , dynamic >;
245+ if (json.containsKey ('additionalData' )) this .additionalData = json['additionalData' ]. cast < String , dynamic >() ;
246246
247247 if (json.containsKey ('backgroundImageLayout' )) {
248- this .backgroundImageLayout = OSAndroidBackgroundImageLayout (json['backgroundImageLayout' ] as Map < dynamic , dynamic >);
248+ this .backgroundImageLayout = OSAndroidBackgroundImageLayout (json['backgroundImageLayout' ]. cast < String , dynamic >() );
249249 }
250250
251251 // raw payload comes as a JSON string
@@ -259,7 +259,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
259259 this .buttons = List <OSActionButton >();
260260 var btns = json['buttons' ] as List <dynamic >;
261261 for (var btn in btns) {
262- var serialized = btn as Map < dynamic , dynamic >;
262+ var serialized = btn. cast < String , dynamic >() ;
263263 this .buttons.add (OSActionButton .fromJson (serialized));
264264 }
265265 }
@@ -279,11 +279,11 @@ class OSNotificationOpenedResult {
279279 OSNotificationAction action;
280280
281281 //constructor
282- OSNotificationOpenedResult (Map <dynamic , dynamic > json) {
283- this .notification = OSNotification (json['notification' ] as Map < dynamic , dynamic >);
282+ OSNotificationOpenedResult (Map <String , dynamic > json) {
283+ this .notification = OSNotification (json['notification' ]. cast < String , dynamic >() );
284284
285285 if (json.containsKey ('action' )) {
286- this .action = OSNotificationAction (json['action' ] as Map < dynamic , dynamic >);
286+ this .action = OSNotificationAction (json['action' ]. cast < String , dynamic >() );
287287 }
288288 }
289289}
@@ -305,7 +305,7 @@ class OSNotificationAction {
305305 /// that the user tapped
306306 String actionId;
307307
308- OSNotificationAction (Map <dynamic , dynamic > json) {
308+ OSNotificationAction (Map <String , dynamic > json) {
309309 this .type = OSNotificationActionType .opened;
310310 this .actionId = json['id' ] as String ;
311311
@@ -330,7 +330,7 @@ class OSActionButton extends JSONStringRepresentable {
330330
331331 OSActionButton ({@required this .id, @required this .text, this .icon});
332332
333- OSActionButton .fromJson (Map <dynamic , dynamic > json) {
333+ OSActionButton .fromJson (Map <String , dynamic > json) {
334334 this .id = json['id' ] as String ;
335335 this .text = json['text' ] as String ;
336336
@@ -366,7 +366,7 @@ class OSAndroidBackgroundImageLayout extends JSONStringRepresentable {
366366 /// The color of the body text
367367 String bodyTextColor;
368368
369- OSAndroidBackgroundImageLayout (Map <dynamic , dynamic > json) {
369+ OSAndroidBackgroundImageLayout (Map <String , dynamic > json) {
370370 if (json.containsKey ('image' )) this .image = json['image' ] as String ;
371371 if (json.containsKey ('titleTextColor' )) this .titleTextColor = json['titleTextColor' ] as String ;
372372 if (json.containsKey ('bodyTextColor' )) this .bodyTextColor = json['bodyTextColor' ] as String ;
0 commit comments