UNotificationInfo.fromMap constructor

UNotificationInfo.fromMap(
  1. Map<Object?, Object?> m
)

Reads it from the native map.

Implementation

factory UNotificationInfo.fromMap(Map<Object?, Object?> m) {
  final Object? raw = m["payload"];
  Map<String, Object?>? payload;
  if (raw is String && raw.isNotEmpty) {
    try {
      payload = (jsonDecode(raw) as Map<Object?, Object?>).map((Object? k, Object? v) => MapEntry<String, Object?>("$k", v));
    } catch (_) {}
  }
  return UNotificationInfo(
    id: (m["id"] as num?)?.toInt() ?? int.tryParse("${m["id"]}") ?? 0,
    title: m["title"] as String?,
    body: m["body"] as String?,
    group: m["group"] as String?,
    next: m["next"] == null ? null : DateTime.fromMillisecondsSinceEpoch((m["next"]! as num).toInt()),
    payload: payload,
  );
}