RemoteMessage.fromMap constructor

RemoteMessage.fromMap(
  1. Map<String, dynamic> map
)

Constructs a RemoteMessage from a raw Map.

Implementation

factory RemoteMessage.fromMap(Map<String, dynamic> map) {
  return RemoteMessage(
    senderId: map['senderId'],
    category: map['category'],
    collapseKey: map['collapseKey'],
    contentAvailable: map['contentAvailable'] ?? false,
    data: map['data'] == null
        ? <String, dynamic>{}
        : Map<String, dynamic>.from(map['data']),
    from: map['from'],
    // Note: using toString on messageId as it can be an int or string when being sent from native.
    messageId: map['messageId']?.toString(),
    messageType: map['messageType'],
    mutableContent: map['mutableContent'] ?? false,
    notification: map['notification'] == null
        ? null
        : RemoteNotification.fromMap(
            Map<String, dynamic>.from(map['notification'])),
    // Note: using toString on sentTime as it can be an int or string when being sent from native.
    sentTime: map['sentTime'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch(
            int.parse(map['sentTime'].toString())),
    threadId: map['threadId'],
    ttl: map['ttl'],
  );
}