PushNotification.fromJson constructor

PushNotification.fromJson(
  1. Map<String, dynamic> json
)

Generate a Push Notification object from JSON. It also supports a <String, String> map which usually comes from Firebase Cloud Messaging.

Implementation

factory PushNotification.fromJson(Map<String, dynamic> json) =>
    PushNotification(
      content: json['content'] is Map
          ? Map<String, dynamic>.from(json['content'])
          : json['content'] is String
              ? jsonDecode(json['content'])
              : null,
      counts: json['counts'] is Map
          ? PushNotificationCounts.fromJson(json['counts'])
          : json['counts'] is String
              ? PushNotificationCounts.fromJson(jsonDecode(json['counts']))
              : null,
      devices: json['devices'] is List
          ? (json['devices'] as List)
              .map((d) => PushNotificationDevice.fromJson(d))
              .toList()
          : (jsonDecode(json['devices']) as List)
              .map((d) => PushNotificationDevice.fromJson(d))
              .toList(),
      eventId: json['event_id'],
      prio: json['prio'],
      roomAlias: json['room_alias'],
      roomId: json['room_id'],
      roomName: json['room_name'],
      sender: json['sender'],
      senderDisplayName: json['sender_display_name'],
      type: json['type'],
    );