[Event] Fix getMapFromPayload

This commit is contained in:
Christian Pauly 2019-08-28 12:57:20 +02:00
parent c33350f796
commit e54f134d92

View file

@ -65,10 +65,11 @@ class RawEvent {
this.unsigned, this.unsigned,
this.room}); this.room});
static Map<String, dynamic> getMapFromPayload(dynamic payload) => static Map<String, dynamic> getMapFromPayload(dynamic payload) {
payload is String if (payload is String) return json.decode(payload);
? json.decode(payload) if (payload is Map<String, dynamic>) return payload;
: payload is Map<String, dynamic> ? payload : null; return null;
}
/// Get a State event from a table row or from the event stream. /// Get a State event from a table row or from the event stream.
factory RawEvent.fromJson(Map<String, dynamic> jsonPayload, Room room) { factory RawEvent.fromJson(Map<String, dynamic> jsonPayload, Room room) {